I have a <select> and I handle change() event. When the user changes the select option I want to perform a series of actions. But, if I trigger the change via $(item).trigger('change') then I do not want to perform said series of actions.
I see trigger() contains an overload with parameters. I’m not sure if this will work as I have not written a custom event. So, what should I do to determine the difference between a user fired event and my programmatic fired event?
Here’s a quick-and-dirty way to do it:
You can do it with the
triggermethod in essentially the same way, and it would eliminate the global, which is a good thing:Working example: http://jsfiddle.net/FishBasketGordo/XsPc5/