Is there any way using jQuery\'s .bind() and .trigger() calls to execute a user defined function (ex: save ()) and act upon the return from the method? For example:
<
I know this question is old, but maybe this can help someone.
As Paliath pointed, you can't return a value because the trigger event is asynchronous. What you can do, is pass a object as parameter to the event. By default, javascript objects are always references to the original.
eg.:
bind:
$(...).bind('example',function (evt,ret) {
ret.val = false;
});
trigger:
var ret = {ret:true};
$(...).trigger('example',[ret]);
if (!ret.ret)
//event return false
else
//event returned true