Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#5532 closed bug (worksforme)

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"});

Change History (3)

comment:1 Changed 11 years ago by mikz

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

comment:2 Changed 11 years ago by pbcomm

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

}

comment:3 Changed 11 years ago by dmethvin

Resolution: worksforme
Status: newclosed

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

Note: See TracTickets for help on using tickets.