2009-02-10 64 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