performing a javascript event without triggering that event handler
Posted
by
bento
on Stack Overflow
See other posts from Stack Overflow
or by bento
Published on 2012-10-25T22:56:39Z
Indexed on
2012/10/25
23:00 UTC
Read the original article
Hit count: 263
In my latest code, I have an event handler for a focus
on a textarea. When the user clicks on the textarea, that event-handler is triggered which sets some other DOM states based on the selected textarea. However, elsewhere in my program I want to programmatically set the focus
of the textarea without triggering that event handler. I know Backbone, for instance, has a way to silently
perform an action.
My only pseudo-solution is to temporarily set a variable:
var silence = true;
And then, in my event handler, only perform the logic if silence is false. The handler is still triggered, but the logic doesn't run.
Does anyone else know of better strategies for this?
© Stack Overflow or respective owner