JQuery Widget Factory覆盖_setOptions

时间:2013-03-26 20:50:16

标签: jquery jquery-widgets

我试图覆盖jQuery Widget Factory的内置_setOptions方法,但我不知道如何调用父_setOptions函数。我使用的是jQuery 1.8.24,因此我无法使用仅在1.9+中提供的super方法。

      _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 Documentation

1 个答案:

答案 0 :(得分:0)

你可以使用this._setOption();