$(document).ready(function(){
jQuery("#but1").bind("click",function(e){
alert(e.name);
});
jQuery("#but1").trigger({name:'Dmy', surname:'My'});
});
The alert fails to pass the data, why is that?!? the alert says ‘undefined’.
What am I doing wrong, why I fail to pass the data?
JSFiddle here.
It’s because the values you pass to trigger come in as other parameters to the click handler, so you can’t access it on the event object. You need to accept an additional paramter.
http://jsfiddle.net/RTXxY/33/