使用jQuery克隆HTMLElements失败得很奇怪
我在jQuery和使用jQuery克隆HTMLElements失败得很奇怪,jquery,events,clone,Jquery,Events,Clone,我在jQuery和.clone(true,true)方面遇到问题。看看 问题是:当我克隆一个对象时(使用.clone(true,true)--deep:data和events),事件可以工作,但会在原始对象(模型对象)上应用所有函数 在阅读代码时,所有内容都将被清除 再见,谢谢您的帮助:)我相信问题在于您大量使用了exampleVariable=$(this) 如果使用变量而不是显式使用$(this),则不使用当前的$(this) 我做了一些改变:(在这里拉小提琴:) 你到底想完成什么?太好了!
.clone(true,true)
方面遇到问题。看看
问题是:当我克隆一个对象时(使用.clone(true,true)
--deep:data和events),事件可以工作,但会在原始对象(模型对象)上应用所有函数
在阅读代码时,所有内容都将被清除
再见,谢谢您的帮助:)我相信问题在于您大量使用了
exampleVariable=$(this)
如果使用变量而不是显式使用$(this)
,则不使用当前的$(this)
我做了一些改变:(在这里拉小提琴:)
你到底想完成什么?太好了!我做了一些修改,工作得更好,但你是完全正确的。谢谢你的帮助。
// 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);
});