Ariel,
>Dan Switzer added a feature request asking for a special property
>added to event objects when the event is triggered by $.trigger().
>
>He provided a test case but I'm not yet convinced. Could you give your
>opinion on this ?
>Additional test cases from many users could help.
>
>I think, in a general way, that if you bind a handler to a certain
>event, then it should work the same for real and fake events. Else,
>maybe you shouldn't be binding or relying on that event, keeping that
>as a function/method instead.
>
>I've seen stuff like:
>$(...).click(function(){...}).click();
>
>And I think that's just wrong. Someone else could had been binding to
>that click too. I'd save a reference to the function and call it w/o
>trigger().
That technically isn't my use case--I was just trying to keep the example
simple. I'm just not sure how to explain the problem in straightforward
matter, but I have run into the problem with a couple of different plug-ins
I've written.
In one plug-in I replace a <select/> element with an anchor tag that
provides all the same functionality of the select.
In my code I use event delegation on a document.click to test to see where
the user clicked. If the user's clicked an item in the list, the option is
changed and with all mouse clicks I hide the menu.
I also have a keypress event bound to the anchor tag. Among many other
things, this handles hiding the menu if the user presses an appropriate key.
I can *not* handle hiding the menu during a blur event, because in some
browsers (like IE) the blur event is fired before the document.click event
and your options never get registered. So, I do not normally want to trigger
hiding the menu on a blur event.
However, what I do want to do is to hide the menu if someone
programmatically calls the blur() event for the anchor tag (which there some
legitimate reasons to do.) For example, I've bound some hotkeys to
automatically scroll to and open these menus. I use trigger the blur()
programmatically when I jump to another field.
So, in this case it makes sense to handle things slightly different based on
the way the event is being fired.
This is just one use case, but like I've said I've had other similar
situations where I wanted to know if the event was real or not.
-Dan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---