March 6, 2012
Can you set event.data with jquery trigger
Question by 9-bits
With jquery .on() you can pass an optional parameter to set the event data. Can you do this with trigger as well?
Answer by Starx
I know an workaround we can use for this
$("button").on("click", function(event) {
event.data = $(this).data('events'); // get the data value
alert(event.data); //use your data as you want
});
//Now set the data value and trigger
$("button").data('events','youreventsvalue').trigger("click");
Here is a demo