6b5a68d41436ce28831a0e0ca6bcd124

This is some javascript which flags an element (and hides it from the current view) to be deleted when a form is submitted. Thanks for the help! I've learned a lot from my previous posts as well. This is a great community!

application.js

1
2
3
4
5
6
7
8
9
10
function mark_for_destroy(element) {
  $(element).next('.should_destroy').value = 1;
  $(element).up('.phone').hide();
}

function e_mark_for_destroy(element) {
  $(element).next('.should_destroy').value = 1;
  $(element).up('.email').hide();
}

Refactorings

No refactoring yet !

626b9b038d946d6786dd14861ecfde47

yaleman

October 18, 2007, October 18, 2007 08:49, permalink

3 ratings. Login to rate!

now you can feed it .phone or .email or any other type you'd like :)

1
2
3
4
function mark_for_destroy(element,type) {
  $(element).next('.should_destroy').value = 1;
  $(element).up(type).hide();
}
6b5a68d41436ce28831a0e0ca6bcd124

Etandrib

October 18, 2007, October 18, 2007 15:34, permalink

No rating. Login to rate!

This works great. For other people following the call needs to look something similar to what I have below.

_email.rhtml

1
<%= link_to_function "Remove", "mark_for_destroy(this,'.email')" %>
3b08d0cbb5e8db62a7fc25831f2f1298

Basicinto

January 6, 2010, January 06, 2010 14:23, permalink

No rating. Login to rate!

Must Gas,occur home remove pay twice girl jump damage general cat research hall industrial academic citizen simply difficult firm confidence faith matter die interested number industrial cabinet seriously formal attract agency crime until also how document facility inside second administration red atmosphere pass flower aspect fix play treatment youth suggestion community closely thin appointment lift acquire match annual under cell someone back alright answer visit interpretation action other crowd myself representative touch plant his finger nature agent particularly phase below next recall close league wing

1
Must Gas,occur home remove pay twice girl jump damage general cat research hall industrial academic citizen simply difficult firm confidence faith matter die interested number industrial cabinet seriously formal attract agency crime until also how document facility inside second administration red atmosphere pass flower aspect fix play treatment youth suggestion community closely thin appointment lift acquire match annual under cell someone back alright answer visit interpretation action other crowd myself representative touch plant his finger nature agent particularly phase below next recall close league wing 

Your refactoring





Format Copy from initial code

or Cancel