2009-02-10 65 views
2

如果(this._ratingValue!= this._currentRating)检查 行为js,在用户点击当前评级星级时,ajax控件工具包中的评级控制不会引发事件,所以我想重写这个方法而不改变js和构建grabit。我该怎么做,我可以扩展评级控制,并覆盖RatingBehavior.js或任何其他解决方案。Ajax控制工具包评级控制 - 覆盖RatingBehavior.js

_onStarClick : function(e) { 
     /// <summary> 
     /// Handler for a star's click event 
     /// </summary> 
     /// <param name="e" type="Sys.UI.DomEvent"> 
     /// Event info 
     /// </param> 
     if (this._readOnly) { 
      return; 
     } 
     if (this._ratingValue != this._currentRating) { 
      this.set_Rating(this._currentRating); 
     } 
    }, 

回答

3

我已经把代码解决它的正上方

function AddNewRatingHandler() { 

     AjaxControlToolkit.RatingBehavior.prototype._onStarClick = 
      function(e) { 
       if (this._readOnly) { 
        return; 
       } 
       // if (this._ratingValue != this._currentRating) {      
       this.set_Rating(this._currentRating); 
       // } 
      }; 
      AjaxControlToolkit.RatingBehavior.prototype.set_Rating = function(value) {      
       // if (this._ratingValue != value) { 
       this._ratingValue = value; 
       this._currentRating = value; 
       if (this.get_isInitialized()) { 
        if ((value < 0) || (value > this._maxRatingValue)) { 
         return; 
        } 

        this._update(); 

        AjaxControlToolkit.RatingBehavior.callBaseMethod(this, 'set_ClientState', [this._ratingValue]); 
        this.raisePropertyChanged('Rating'); 
        this.raiseRated(this._currentRating); 
        this._waitingMode(true); 

        var args = this._currentRating + ";" + this._tag; 
        var id = this._callbackID; 

        if (this._autoPostBack) { 
         __doPostBack(id, args); 
        } 
        else { 
         WebForm_DoCallback(id, args, this._receiveServerData, this, this._onError, true) 
        } 

       } 
       // } 
      };     
    } 
    AddNewRatingHandler(); 

</script> 



</div> 

</form> 
+0

我想这样做,但它似乎并没有产生任何影响。除了将此代码添加到我的aspx页面之外,还有什么需要做的吗? – merk 2012-01-29 20:21:57