Stop the drag event while clicking on the link

I have a drag event over an attached div.image. enter image description here

when i click on the div, drag the start.for this event i include nestable.js plugin.i want to stop the drag and drop event of the div while clicking on the links div.i am using js and html file from the link: Nestable

Please give a decision on how I can do this.

+5
source share
5 answers

To ignore click processing, add the "dd-nodrag" class to the element.

+14
source

the author has a problem with the embedded plugin. There is a better way to solve the problem of clicking a link that fits in a nesting container:

$(".dd a").on("mousedown", function(event) { // mousedown prevent nestable click
    event.preventDefault();
    return false;
});

$(".dd a").on("click", function(event) { // click event
    event.preventDefault();
    window.location = $(this).attr("href");
    return false;
});

.dd - , ,

+4

You need to prevent the click event from spreading from the link element.

Example:

$('#div').on('click', 'a', function(){
    return false;
})
+2
source

You can disable this using your own CSS class.

.disableDrag{
  display: block;
  margin: 5px 0;
  padding: 6px 10px 8px 40px;
  font-size: 15px;
  color: #333333;
  text-decoration: none;
  border: 1px solid #cfcfcf;
  background: #fbfbfb;
}

Use the generated CSS class in the element where you want to disable.

JSFiddle working example

<li class="dd-item"> <div class="disableDrag"><em class="badge pull-right"></em></div> </li>
0
source
<div class="dd-handle">
ID - Title <a href="#" class="dd-nodrag link_min">Link</a>

.link_min{
  position: absolute;
  display: inline-block;
  right: 0px;
  margin-right: 8px;
}
0
source

All Articles