Skip to main content

Bug Tracker

Side navigation

#5532 closed bug (worksforme)

Opened November 18, 2009 07:21PM UTC

Closed November 18, 2009 10:49PM UTC

Last modified March 15, 2012 06:53PM UTC

jQuery.trigger doesn't pass data argument when its object with length property

Reported by: mikz Owned by: brandon
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: makeArray, length Cc:
Blocked by: Blocking:
Description

jQuery.trigger (and probably more functions) doesn't pass data when it's Object with length property. jQuery.makeArray doesn't recognize this object and tries to make array from it, which returns undefined.

Test:

$("body").bind("custom", function(event, data) {

console.log(data);

});

$("body").trigger("custom", {length: "fails"});

$("body").trigger("custom", {test: "passes"});

Attachments (0)
Change History (3)

Changed November 18, 2009 07:25PM UTC by mikz comment:1

workaround:

$("body").trigger("custom", [ {test: "passes"} ]);

Changed November 18, 2009 07:39PM UTC by pbcomm comment:2

Mikz, read the docs to trigger. The data has to be an array and is passed along as arguments to the event handler.

$("body").trigger("custom", [ {test: "passes"}, 'more', 'args' ]);

custom = function(e, one, two, three) {

one === object

one.test === passes

two === more

three === args

}

Changed November 18, 2009 10:49PM UTC by dmethvin comment:3

resolution: → worksforme
status: newclosed

Yep, if you pass an Array as documented it works fine.