Commit 3261544c authored by John Resig's avatar John Resig

Fixed #2027 - make sure that cloned elements (within appendTo, etc.) have...

Fixed #2027 - make sure that cloned elements (within appendTo, etc.) have their events cloned by default.
parent b740fe56
...@@ -498,7 +498,7 @@ jQuery.fn = jQuery.prototype = { ...@@ -498,7 +498,7 @@ jQuery.fn = jQuery.prototype = {
jQuery.each(elems, function(){ jQuery.each(elems, function(){
var elem = clone ? var elem = clone ?
this.cloneNode( true ) : jQuery( this ).clone( true )[0] :
this; this;
// execute all scripts after the elements have been injected // execute all scripts after the elements have been injected
......
module("event"); module("event");
test("bind()", function() { test("bind()", function() {
expect(18); expect(19);
var handler = function(event) { var handler = function(event) {
ok( event.data, "bind() with data, check passed data exists" ); ok( event.data, "bind() with data, check passed data exists" );
...@@ -85,6 +85,11 @@ test("bind()", function() { ...@@ -85,6 +85,11 @@ test("bind()", function() {
$("#nonnodes").contents().bind("tester", function () { $("#nonnodes").contents().bind("tester", function () {
equals(this.nodeType, 1, "Check node,textnode,comment bind just does real nodes" ); equals(this.nodeType, 1, "Check node,textnode,comment bind just does real nodes" );
}).trigger("tester"); }).trigger("tester");
// Make sure events stick with appendTo'd elements (which are cloned) #2027
$("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("p");
ok( $("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );
reset();
}); });
test("click()", function() { test("click()", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment