我正在尝试覆盖 jQuery Widget Factory 的内置 _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();
},