Skip to content Skip to sidebar Skip to footer

Jquery How To Set A Binding Order

is there a way to set a binding over, precedence? I have a link like so: popItUp binds to take the url and open in

Solution 1:

Instead of returning false, why not simple prevent the default action?

 $('.popItUp').click(function(e)
 {
      e.preventDefault();

      // Do Stuff
 });

That way, the event just isnt canceled, it just doesnt perform the default action.

Solution 2:

If popItUp handler is bound first and if it returns false then data-track binding will not be called. You need to bind data-track binding first if at all you want to give it more precedence and not matter what popItUp does.

Looking at your edited question, data-track binding is done using live which works on event bubbling mechanism. If popItUp handler returns false then it is not going to work. May be you can try to prevent default behavior using e.preventDefault(); of anchor instead of returning false inside the popItUp handler.

Solution 3:

live works by catching events that bubble up to the <body> tag.

Therefore, any handlers added directly to an element will run before live handlers. Calling stopPropagation() (or return false) inside direct handlers will prevent it from bubbling, so live won't catch it.

Post a Comment for "Jquery How To Set A Binding Order"