Out of curiosity -- what is the purpose of / use cases for jQuery's triggerHandler
? As far as I can tell, the only "real" differences between trigger
and triggerHandler
is whether or not the native event fires, and event bubbling behavior (though triggerHandler
's bubbling behavior doesn't seem hard to replicate with trigger
in a few more lines of code). What is the advantage to ensuring the native event does not fire?
I'm curious if this is a convenience function or there's a deeper reason it exists, and what why/when I would use it.
You have actions bound to a 'focus' event but you don't want the browser to focus really focus it (might seem dumb but it could happen, couldn't it? like a code that you would like to execute once without losing the current focus).
A component that you are making want to trigger 'load' (just an example of a generic thing) of another component that is inside it.
In that case, if you are calling 'load' of children when 'load' of the parent comes, you don't want to do this because it would cause an infinite call if the event.stopPropagation isn't called by the listeners of 'load' event (caused by bubling):
In that case you have to call triggerHandler().