开发者

issue when Upgrading to jQuery 1.5.1

开发者 https://www.devze.com 2023-02-14 08:38 出处:网络
the delete link don\'t work when I upgrading from jquery 1.5 to jquery 1.5.1开发者_如何学编程:

the delete link don't work when I upgrading from jquery 1.5 to jquery 1.5.1开发者_如何学编程:

Demo: http://jsfiddle.net/EfsGN/


This was a bug with the clone() method that was introduced in jQuery 1.5, and fixed in 1.5.1.

The default behaviour with clone() should be to not copy the events and data of the cloned element, however this was not the case with 1.5 (where the default behaviour was to copy the events).

To fix your code, change:

$('#add-input').click(function() {
    main.append(clonedField.clone());
    return false;
});

to

$('#add-input').click(function() {
    main.append(clonedField.clone(true));
    return false;
});

Working fiddle: http://jsfiddle.net/EfsGN/7/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号