0

As it seems like I have found a bug in jquery:
jquery draggable throws error when 'mouseup' is triggered Can I get some advice on how to implement the following functionality without using the trigger? I want to be able to stop an element to be dragged when a condition has been reached, I have been trying lot's of possibilities but none works automatically, even though the event is fired when condition is true it only takes effect when you "mouseup" the dragger. I'm really trapped on this, any help will be very appreciated. P.D: I have already posted the bug in jquery.ui

Community
  • 1
  • 1
Moustard
  • 347
  • 1
  • 3
  • 11

1 Answers1

0

The following piece of code worked for me well. There isn't any method that cancels only one "dragging", but you can set the position of the object using ui.position

$('#draggablediv').draggable({
        drag: function (event, ui) {
            if (your_condition) { // for example: ui.position.left < 100
                ui.position.left = ui.position.left_old
                ui.position.top = ui.position.top_old
            }
            ui.position.left_old = ui.position.left
            ui.position.top_old = ui.position.top
        }
    })
Esenbek Kydyr uulu
  • 1,553
  • 1
  • 14
  • 19