jquery: pass an object to event handler using jquery trigger method -


The following code is not working to pass an object to the event handler:
  $ ('(' click ', function (e, data)) {alert (data); // * * Alerts' [[HamineClick: True]] '** Warning (data.isamachineclick); // * * alert' undefined '**}); $ (' A.another '). Trigger (' click ','   

Please take a look at this.

PS: The solution given on the link is not working, therefore Posting a new thread .

You are passing only one string, and within the more string JSON is an array, the object Try it:

  $ ('a.another') live ('click', function (e, data) {warning (data [0] .isMachineClick);}) ; $ ('A.another') Trigger ('click', [[MashinKalik: true]];   

UPDATE : Did not realize that How it works: The use of an array is right, and each additional item becomes another argument. This is the correct code :

  $ ('a.another'). Live ('Click', Function (E, Data, Data 2) {Warning (data.isMachineClick); Alert (Data 2 .someOtherThing);}); $ ('A.another'). Triggers ('Click', [[MashinKalik: Truth], {Some Ootherthong: False}]);    

Comments