Skip to content

Instantly share code, notes, and snippets.

@ronmichael
Last active December 18, 2015 18:19
Show Gist options
  • Save ronmichael/5825279 to your computer and use it in GitHub Desktop.
Save ronmichael/5825279 to your computer and use it in GitHub Desktop.
Extend jQuery UI
// add some functions (or override some functions)
// e.g. $(selector).autocomplete("doMore", data);
$.widget("ui.autocomplete", $.ui.autocomplete, {
doMore: function (data) {
// this = autocomplete object
// this.element = auto complete input element
},
overRideBlur: function() {
this._on(this.element, {
blur: function (event) {
// the standard blur code
if (this.cancelBlur) {
delete this.cancelBlur;
return;
}
clearTimeout(this.searching);
this.close(event);
this._change(event);
// raise an extra event
$(this.element).trigger("autocompleteblur");
}
});
}
});
$.widget("ui.autocomplete", $.extend({}, $.ui.autocomplete.prototype, {
_search: function (value) {
this.pending++;
this.element.addClass("ui-autocomplete-loading");
this.cancelSearch = false;
this.source({ term: value }, this._response());
}
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment