How can I prevent link to link when I move links using drag & drop?

I allow move (drag & drop) some elements that contain an internal link ( a), after the user canceled it, it redirects the browser to the hrefmoved element. How can I let this item click and drag and drop it? I am using the http://dragsort.codeplex.com/ plugin.

+3
source share
2 answers

You would prevent the default behavior on links, buttons, etc. using preventDefault();

$( ".selector" ).draggable({
   stop: function(event, ui) {
         // Do some stuff when you've finished dragging your element
         event.preventDefault(); }
});

Learn more about the jQuery API .

+1
source

event.preventDefault(), , . , , , -vs- . , , :

$('.something').click(function(event) { 
    if ($(this).data('dragging')) {
        event.preventDefault();
        $(this).data('dragging',false);
    }
}
0

All Articles