Skip to main content

Bug Tracker

Side navigation

#7043 closed feature (duplicate)

Opened September 17, 2010 06:39AM UTC

Closed September 21, 2010 03:53AM UTC

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.

Attachments (0)
Change History (2)

Changed September 18, 2010 02:35AM UTC by dmethvin comment:1

Dup of #6184.

Changed September 21, 2010 03:53AM UTC by snover comment:2

resolution: → duplicate
status: newclosed