JavaScript
Combining javascript for 2+ models
Posted
October 17, 2007 21:32
by
Etandrib
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();
}
## application.js
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 !
October 18, 2007,
October 18, 2007 08:49,
permalink
3 ratings.
Login to rate!
1
2
3
4
function mark_for_destroy(element,type) {
$(element).next('.should_destroy').value = 1;
$(element).up(type).hide();
}
October 18, 2007,
October 18, 2007 15:34,
permalink
No rating.
Login to rate!
_email.rhtml
1
<%= link_to_function "Remove", "mark_for_destroy(this,'.email')" %>
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!