On 9/11/06, John Resig <[EMAIL PROTECTED]> wrote:
> The triggered function should receive two arguments (in this case).
> The first one is the fake event, the second one is the new data item.
> Let me know if this is not the case.
Oops, that's not the case. This is the code I've used for testing:
$(f);
function f() {
$("#coso")
.bind("afterValidate", handler)
.trigger("afterValidate", ["extraData"]);
}
function handler(e, data) {
alert(data); // outputs "undefined"
}
-- Some minutes later --
I´ve solved this issue provisionally by modifying `jQuery.event.handle`:
handle: function(event, data) {
// ...
for ( var j in c ) {
if ( c[j].apply( this, [event, data] ) === false ) {
// ...
}
}
// ...
}
I really really need this issue to be fixed (maybe with a better solution).
(By the way, all of this is under Rev. 289).
> On 9/11/06, Choan C. Gálvez <[EMAIL PROTECTED]> wrote:
> > Hi all.
> >
> > I'm developing a validation system which involves custom events
> > handling. That is, I want to execute some code before the validation
> > and some code after the validation.
> >
> > So, my `$.fn.validate` looks like this (simplified):
> >
> > $.fn.validate = function(callback) {
> > return this.each(function() {
> > var res;
> > var $this = $(this);
> > $this.trigger("beforeValidate");
> > res = validationExecution(); // edited to simplify
> > $this.trigger("afterValidate", [res]); // <-- look at this
> > line
> > });
> > };
> >
> > Trouble is, while the `$("something").trigger("event", data)` allows
> > passing extra data to the handler (as seen inside `$.fn.trigger` and
> > `$.event.trigger`), the handler function receives just a param, which
> > is the real-or-fake event.
> >
> > Reason to want this feature is that the `afterValidate` handler must
> > know if the validation has been succesfull to proceed in one of two
> > manner (succesfull/unsuccesfull).
> >
> > Any workaround for this? Should I create a ticket?
--
Choan
<http://choangalvez.nom.es/>
Dizque. Desarrollo web y pequeñas dosis de vida real
<http://dizque.lacalabaza.net>
Mundo Du. Cuentos breves, relatos sorprendentes
<http://du.lacalabaza.net/>
Scriptia. Javascript y buenas prácticas
<http://scriptia.net/>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/