How to stop a function from other function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 21

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.

16th Jul 2020, 3:42 PM
You
You - avatar
19 Answers
+ 12
You could execute the code only if a variable is true. And set the variable to false to stop the function. https://code.sololearn.com/W3X87tc5aTbD/?ref=app
16th Jul 2020, 4:04 PM
Arnesh
Arnesh - avatar
+ 8
16th Jul 2020, 3:57 PM
You
You - avatar
+ 7
Infinite it is working on normal event listeners but not in draggable
16th Jul 2020, 7:22 PM
You
You - avatar
+ 6
Are u using jquery ui?
16th Jul 2020, 3:53 PM
ㅤ Tweetu 😆 ㅤㅤ
ㅤ  Tweetu 😆 ㅤㅤ - avatar
16th Jul 2020, 4:16 PM
Cyber Nate
Cyber Nate - avatar
+ 5
Big Secret after drag u want to drop somewhere on page ???... What u actually want to do ?...
16th Jul 2020, 5:20 PM
ㅤ Tweetu 😆 ㅤㅤ
ㅤ  Tweetu 😆 ㅤㅤ - avatar
+ 5
F3tcher now the element id draggable and dropable . I want that when a button is clicked , the object loses its draggability
16th Jul 2020, 5:44 PM
You
You - avatar
+ 5
Arnesh its not working in my code bro. Tke the same example of draggable and then check
16th Jul 2020, 5:46 PM
You
You - avatar
+ 5
Infinite i tried it i didn't worked
16th Jul 2020, 6:03 PM
You
You - avatar
+ 4
Big Secret i hope you are able to use this code to manipulate it. https://code.sololearn.com/WDkKrPQO688L/?ref=app
16th Jul 2020, 7:07 PM
Infinite
Infinite - avatar
+ 4
Big Secret i haven't actually used draggable, but i would inbox you if i'm able to
16th Jul 2020, 7:24 PM
Infinite
Infinite - avatar
+ 4
Big Secret, check this out, it works. With drag and drop. https://code.sololearn.com/WDUCEvb59QV4/#html For drag and drop, you need to set draggable to false or it will seem as if it is draggable
17th Jul 2020, 8:25 AM
Arnesh
Arnesh - avatar
+ 4
Arnesh No its not working its not even dragging that box
17th Jul 2020, 9:16 AM
You
You - avatar
+ 4
Arnesh Thankyou
17th Jul 2020, 1:00 PM
You
You - avatar
+ 3
Big Secret i think you should use a clearInterval on your code(I.e you should clear the interval when a button is clicked)
16th Jul 2020, 5:59 PM
Infinite
Infinite - avatar
+ 3
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
16th Jul 2020, 6:04 PM
Infinite
Infinite - avatar
+ 3
Big Secret sorry i wasn't able to solve it using dragganble. Really don't know much about draggable
16th Jul 2020, 6:54 PM
Infinite
Infinite - avatar
+ 3
Well, if you aren't using drag and drop API, and moving around the div with touchmove/mousemove... https://code.sololearn.com/W6NX8hAV5Zp3/?ref=app
17th Jul 2020, 11:49 AM
Arnesh
Arnesh - avatar
+ 2
It works(drag and drop doesn't work on the phone)🙄
17th Jul 2020, 11:08 AM
Arnesh
Arnesh - avatar