I am overriding the jquery ui method for close. In this way, I can have it close based on a selected variable I establish.
var originalCloseMethod = $input.data("autocomplete").close();
$input.data("autocomplete").close = function(event) {
if (!selected){
originalCloseMethod.apply(this, arguments);
}
selected = false;
};
It works great except for when it needs to make a regular closer. For example, if I click outside of the autocomplete div. The API then calls for close and returns this :
originalCloseMethod is undefined
Which makes me realize that it’s calling this method internally inside the UI.
This is why I am assuming that the best way to write this code, is to extend the UI not just override it.
My question is, how would I apply this same method as an extension as opposed to an override?
You call the close function and save it’s return value, not saving a reference to it:
Change it to: