Bug Tracker

Opened 12 years ago

Closed 12 years ago

#6993 closed enhancement (fixed)

.bind() and .one() don't allow a function as data

Reported by: davidflanagan Owned by: john
Priority: low Milestone: 1.6
Component: event Version: 1.4.3
Keywords: Cc:
Blocked by: Blocking:


The .bind() and .one() methods take two or three arguments, and have the signatures:

bind(type, data, handler) bind(type, handler)

Currently, jQuery 1.4.2 distinguishes these cases with this code:

if ( jQuery.isFunction( data ) ) {

fn = data; data = undefined;


This means that if you pass a function as the data argument, it will be treated as the handler argument and the handler will be ignored.

I propose that you change the code to instead test like this:

if (arguments.length === 2) {

fn = data; data = undefined;


Change History (5)

comment:1 Changed 12 years ago by davidflanagan

See line 2371 in jquery-1.4.2.js for the code referred to above. (It doesn't look right the way I pasted it into the ticket.)

comment:2 Changed 12 years ago by snover

Milestone: 1.4.31.next
Priority: low
Status: newopen
Type: bugenhancement

comment:3 Changed 12 years ago by snover


Retarget all enhancements/features to next major version.

comment:4 Changed 12 years ago by john

Milestone: 1.6
Owner: set to john
Status: openassigned

comment:5 Changed 12 years ago by John Resig

Resolution: fixed
Status: assignedclosed

Allow function to be passed in as a data object to bind and one. Fixes #6993.

Changeset: 6e3b596514d20124260bc4b3febd8dc105420626

Note: See TracTickets for help on using tickets.