我试图覆盖jQuery小部件工厂的内置_setOptions方法,但我不知道如何调用父_setOptions函数。我正在使用jQuery 1.8.24,所以我不能使用super
方法,只有1.9+可用。
_setOption: function(key, value){
console.log('key => '+ key + '; value => '+ value); // Test to see if this gets called
if(this[key] != value) {
$.Widget.prototype._setOption.apply(this,arguments); // Call the parent option
}
},
_setOptions: function(options){
console.log('Config multi options');
console.log(options);
//$.Widget.prototype._setOptions.apply(this, options); // throws error
// Ripped out the guts of Widget _setOptions for now. Feels hackish.
var self = this;
$.each(options, function(key, value) {
self._setOption(key, value);
});
// What to do after finished setting multiple options.
this._configureVideo();
this.play();
},
jquery UI 1.9 WidgetFactory文档
可以使用this._setOption();