bind jquery event on event -


I'm listening to a click event. When triggered, I need to force a different event (for another element), but it keeps on triggering both at the first event.

My code:

  $ (". Element1"). ("Click", function () {console.log ("trigger element 2" on ("click", function () {console.log ("trigger element 1"); $ (".element2"). );})});    

A separate copy of the event handler for .element2 every The bar will be clicked on .element1 . If you want to stop it, remember in a variable that you have already made the handler.

  var e2bound = false; $ ("Element1") ("Click", function () {console.log ("trigger element 1"); if (! E2bound) {$ (". Element2"). ("Click", function () {Console.log ("Trigger element 2");}) e2bound = true;}});   

An alternative solution will be to shut down the first driver when it runs:

  $ (". Element1"). ("Click", function ("click", e1handler); $ (". Element2") ("click", function () {console.log ("click", "trigger element 2") ;})});    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -