fix some slow javascript. oops

This commit is contained in:
John Bintz 2013-04-10 18:34:47 -04:00
parent 996ccd55f0
commit 7b8cd65a55
2 changed files with 6 additions and 5 deletions

View File

@ -11,7 +11,7 @@
return $(this).parent().siblings(selector); return $(this).parent().siblings(selector);
} }
$('.add_fields').live('click', function(e) { $(document).on('click', '.add_fields', function(e) {
e.preventDefault(); e.preventDefault();
var $this = $(this), var $this = $(this),
assoc = $this.data('association'), assoc = $this.data('association'),
@ -67,7 +67,6 @@
trigger_node.trigger('cocoon:before-remove', [node_to_delete]); trigger_node.trigger('cocoon:before-remove', [node_to_delete]);
var timeout = trigger_node.data('remove-timeout') || 0; var timeout = trigger_node.data('remove-timeout') || 0;
setTimeout( setTimeout(

View File

@ -1,8 +1,7 @@
//= require jquery.ui.all
//
(function($) { (function($) {
$.cocoon = { $.cocoon = {
ordered: { ordered: {
isSetUp: false,
options: { options: {
items: '> .nested-fields', items: '> .nested-fields',
stop: function(e, ui) { stop: function(e, ui) {
@ -74,7 +73,10 @@
}); });
}); });
$(document).on('cocoon:after-insert', function() { $.cocoon.ordered.setup(); }); if (!$.cocoon.ordered.isSetUp) {
$(document).on('cocoon:after-insert', function() { $.cocoon.ordered.setup(); });
$.cocoon.ordered.isSetUp = true;
}
} }
}, },
}; };