Skip to main content

Bug Tracker

Side navigation

#5411 closed bug (invalid)

Opened October 27, 2009 04:30PM UTC

Closed October 27, 2010 10:21PM UTC

Cannot use prototype methods for event handler

Reported by: dinoboff Owned by: brandon
Priority: low Milestone: 1.4
Component: event Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:

Here is the test:

test("Use prototype method as event handler", function(){
	var $elem = $('#swipeTarget'),
		SomeConstructor = function($elem) {
			$elem.bind('test', this, this.handler);
	SomeConstructor.prototype = {
		handler: function() {
                        var that =;
                        ok(true, "Called.");}
	obj1 = new SomeConstructor($elem);
	obj2 = new SomeConstructor($elem);

The test will fail. Only obj2.handler will be called.

jQuery tracks event handler (for unbind) by adding them an unique guid property, and only one guid / element / event can be registered. In this case obj1.handler and obj2.handler are the same function and share the same guid.

Attachments (0)
Change History (1)

Changed October 27, 2010 10:21PM UTC by rwaldron comment:1

priority: majorlow
resolution: → invalid
status: newclosed

The test case contained incorrect code to achieve the desired result.