It might me due to the insomnia, but I've been having trouble getting the following, simple JS function to work.
function numFunction() {
var retNum = null;
$('.draggable').draggable($state).on("drag", function (event, ui) {
retNum = 31;
});
return retNum;
}
var finNum = numFunction();
It is as easy as this:
- We start of by creating a function with the name
numFunction
. - The variable
retNum
is defined. The variable changes its value due to an event triggered by jQuery UI draggable (which works perfectly fine). - Return
retNum
- Last but not least, define new variable
finNum
with function's (supposed) new value of31
. - End of story.
Unfortunately, it doesn't work. console.log(finNum)
only returns null
. I am about to bash my head against the wall: I don't know what I am missing.