How to use a variable in / across a "dot operator" or across widget options
I have an Autocomplete and I change some of the choices in the dropdown list via the renderItem function. That much works. If the user selects a changed choice, I want to make a different select: than if they select an unchanged choice in the list. So far, a click on a changed choice causes the select: option to do its normal thing. It seems I need to change a variable from 0 to 1 when changed choices appear, and then use an if statement in the select: option to determine which select action to take. I can do this with a global variable. I don't see how to do this without a global variable. The renderItem function is a "dot addition" at the end of the Autocomplete function - its not inside the Autocomplete function. Is it possible to pass variable values between widget options or across the dot separator - if so, how? Here's the structure of the code using the global var override.
$("#city").autocomplete({
source: //do stuff via ajax
select: function (event, ui){
if (override == 1){
//set selected value one way
}
//set selected value another way
}
}).data("autocomplete")._renderItem = function (ul, item){
var listItem = $("<li></li>")
.data("item.autocomplete", item)
if ( item.label == "trigger" ){
override = 1;
listItem.html( //change list item );
} else {
override = 0;
listItem.html( // list item does not change );
}
return listItem.appendTo(ul);
}