Opened 12 years ago
Closed 12 years ago
#7043 closed feature (duplicate)
Error when unbind is called on non-element
Reported by: | scott_h | Owned by: | |
---|---|---|---|
Priority: | Milestone: | 1.4.3 | |
Component: | event | Version: | 1.4.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery.data() works with non-element targets. Therefore, jQuery events should work with non-element targets.
var a = {}; jQuery(a).bind("x", function() { console.log("event fired on non-element target") }); jQuery(a).trigger("x"); //=> "event fired on non-element target" jQuery(a).unbind("x"); //=> TypeError: Result of expression 'elem.removeEventListener' [undefined] is not a function. [jquery.js, line 2070] jQuery(a).trigger("x"); //=> "event fired on non-element target"
They do, except for unbind() which throws an error. I realise this isn't intended use of jQuery and may never be officially supported since other methods like append() will throw errors too, but custom event targets are so useful and this is potentially be a very minor change.
Change History (2)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
Dup of #6184.