This is a function used in jQuery UI widgets and plugins -
var select = function( event, ui ) {
var somevariable = 4;
}
How can I get the value of var somevariable =
outside this function?
Using it as a global variable doesn't work:
var somevariable;
var select = function( event, ui ) {
var somevariable = 4;
}
In this code var somevariable
doesn't get the value '4' when it is placed before or after var select =
EDIT: To make it more detailed, I want to use this variable in another function like in the following jQuery UI plugin:
$( "#id" ).autocomplete({
minLength: 0,
source: function( request, response ) {
if (somevariable == 5)
{
//do something
}
},
open: function( event, ui ) {
somevariable = 5;
}
});
In this case when the open:
event is triggered, the value does not get retrieved by source: