我对jQuery和.clone(true, true)有意见。看看在这个jsFiddle上。
问题是:当我克隆一个对象(使用.clone(true, true) -- deep: data和events)时,这些事件可以工作,但是在原始对象(模型对象)上应用所有函数。
所有的阅读代码都将是清晰的。
再见,谢谢您的帮助:)
发布于 2011-06-10 18:27:40
我认为问题在于您广泛使用exampleVariable = $(this)。
当您使用变量而不是显式使用$(this)时,如果这有任何意义的话,就不会使用当前的$(this)。
我做了一些改变:(小提琴这里:http://jsfiddle.net/PGM6W/)
// On click on more, append a new model
// Will update table buttons too
// THIS WORKS FINE, except if I click on remove and click on this two times (try it)
selfRow.find('a.more').click(function(){
$(this).parents("table").append(model.clone(true, true));
updateModel(selfTable);
});
// On click on remove, will remove current row
// Will update table buttons too
// THIS NOT WORKS FINE, and broke the a.more event!
selfRow.find('a.remove').click(function(){
$(this).remove();
updateModel(selfTable);
});https://stackoverflow.com/questions/6310403
复制相似问题