0

我有点困惑为什么这个新铸造的 jQuery UI 小部件没有选项方法?

(function ($) {
    $.widget('ui.oTest', {
        options: {},
        _create: function(){
             $('<span>',{
                 html: 'oTest Span'
             }).appendTo(this.element);
        }
    });
})(jQuery);

$('.test').oTest();
$('.test').option(); //Uncaught TypeError: Object [object Object] has no method 'option' 

这是小提琴:http: //jsfiddle.net/fwWc8/

谢谢!

4

1 回答 1

0

解决方案:文档中不是很清楚,但是使用以下设置选项:

$('.test').oTest('option', {'string': 'meow'});

http://learn.jquery.com/plugins/stateful-plugins-with-widget-factory/

于 2014-05-07T19:23:33.897 回答