How to stop a function from other function | Sololearn: Learn to code for FREE!


How to stop a function from other function

Like I have this code function drag(){ $('.e').draggable() } How do I stop this function from another function.

7/16/2020 3:42:43 PM


20 Answers

New Answer


You could execute the code only if a variable is true. And set the variable to false to stop the function.


F3tcher yes


Infinite it is working on normal event listeners but not in draggable


Are u using jquery ui?

+6 Check, I think this should help you out sis


Big Secret after drag u want to drop somewhere on page ???... What u actually want to do ?...


F3tcher now the element id draggable and dropable . I want that when a button is clicked , the object loses its draggability


Arnesh its not working in my code bro. Tke the same example of draggable and then check


Infinite i tried it i didn't worked


Big Secret i hope you are able to use this code to manipulate it.


Big Secret i haven't actually used draggable, but i would inbox you if i'm able to


Big Secret, check this out, it works. With drag and drop. For drag and drop, you need to set draggable to false or it will seem as if it is draggable


Arnesh No its not working its not even dragging that box


Arnesh Thankyou


Big Secret i think you should use a clearInterval on your code(I.e you should clear the interval when a button is clicked)


Big Secret i will try work on an example to show you. But i may not use draggable, maybe other event handles(click, etc). hope that's okay


Big Secret sorry i wasn't able to solve it using dragganble. Really don't know much about draggable


Well, if you aren't using drag and drop API, and moving around the div with touchmove/mousemove...


It works(drag and drop doesn't work on the phone)🙄