开发者

How to extend jQuery UI widget _create method?

开发者 https://www.devze.com 2023-02-09 15:28 出处:网络
I\'m having a LOT of pain trying to do something very simple : extend a jQuery UI widget, namely the autocomplete one.

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消