jQuery UI Widget - 对象没有方法_super

dar*_*uby 0 javascript jquery jquery-ui

调用基类方法对我来说似乎不起作用.我有以下设置:

...
<div class='my'></div>
...
Run Code Online (Sandbox Code Playgroud)

和Javascript

$.widget('tt.name1',{
    _create: function() {
        this.name = 'name'
        console.log('-->', this.name);
    }
});

$.widget('tt.name2',$.tt.name1, {
    _create: function() {
        this._super();
        /*$.tt.name1.prototype._create.call(this);*/
        this.name = 'name2'
        console.log('-->', this.name);
    }
});

$('.my').name1();
$('.my').name2();
Run Code Online (Sandbox Code Playgroud)

调用时会产生以下输出和错误 this._super()

- > name
Uncaught TypeError:Object#没有方法'_super'

两个链接表明它应该工作

尝试行动

And*_*ker 6

这些示例使用jQuery 1.9中引入的小部件工厂.您的示例使用1.8.9.如果升级到1.9,您的代码将正常工作.