0

I have several jQuery event listener on several links in a matrix (it's a map parcel selection). Now i already prevent the default action on mousedown, but if i prevent the action on mouseup, it doesn't work. I prevent the default action on mousedown on a link and start "marking" elements from there on. If a "mouseup" occurs in the same Element, the link get's executed.

So what i need to do is prevent link execution in mouseup, but it doesn't work.

$('a.parcel').on('mouseup',function(event){
    event.preventDefault();
});

This still executes the link that is given in the href of the a element.

Any Ideas anyone?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Andresch Serj
  • 35,217
  • 15
  • 59
  • 101

1 Answers1

2

The default action you are preventing on the mouseup event is not responsible for changing the href. That being said, it doesn't matter if you prevent it or not, the href gets executed on the click event.

The click event gets fired after mousedown, so changing the mouseup to click should work just fine.

whitneyit
  • 1,226
  • 8
  • 17
  • I just added an additional on('click',...) Listener that prevents the event. Should have been a no-brainer. Thanks still! – Andresch Serj Feb 07 '13 at 12:36
  • @AndreschSerj If I understood you correctly, you could do it like this: http://jsfiddle.net/lollero/RaFFK/show OR multiple links: http://jsfiddle.net/lollero/RaFFK/1/show/ – Joonas Feb 07 '13 at 12:48