mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Make jQuery().off(event) work for delegated events.
Logic to handle detaching by event was in both .off() and jQuery.event.remove; now it's only in .off(). It's a bit of a strange case since the event object (not the jQuery set) specifies the element.
This commit is contained in:
@@ -2054,6 +2054,20 @@ test(".delegate()/.undelegate()", function() {
|
||||
jQuery("#body").undelegate("#nothiddendiv div", "click");
|
||||
});
|
||||
|
||||
test("jQuery.off using dispatched jQuery.Event", function() {
|
||||
expect(1);
|
||||
|
||||
var markup = jQuery( '<p><a href="#">target</a></p>' ),
|
||||
count = 0;
|
||||
markup
|
||||
.on( "click.name", "a", function( event ) {
|
||||
equals( ++count, 1, "event called once before removal" );
|
||||
jQuery().off( event );
|
||||
})
|
||||
.find( "a" ).click().click().end()
|
||||
.remove();
|
||||
});
|
||||
|
||||
test("stopPropagation() stops directly-bound events on delegated target", function() {
|
||||
expect(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user