Modify ↓
Ticket #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: | ||
| Blocking: | Blocked by: |
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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Dup of #6184.