How to extend jQuery UI widget _create method?
I'm having a LOT of pain trying to do something very simple : extend a jQuery UI widget, namely the autocomplete one.
Here is what I am doing :
(function($) {
$.widget("my.autocomplete", $.extend({}, $.ui.autocomplete.prototype, {
_create: function() {
$.Widget.prototype._create.apply(this, arguments);
},
}));
})(jQuery);
Of course, it doesn't work even though it is exactly what the official jQuery UI documentation recommends :
http://jqueryui.com/docs/Dev开发者_C百科eloper_Guide
Can someone help on this ? I'm confused and have been stuck for many hours now...
Thanks by advance,
Eric.
OK, I've found the answer after many hours of confusion :
$.ui.autocomplete.prototype._create.apply(this, arguments);
Instead of :
$.Widget.prototype._create.apply(this, arguments);
Working like a charm...
精彩评论