【问题标题】:Ajax control toolkit Rating Control- Override RatingBehavior.jsAjax 控制工具包 Rating Control- Override RatingBehavior.js
【发布时间】:2009-02-10 04:39:14
【问题描述】:

如果用户点击当前评分星,Ajax 控制工具包中的评分控件不会引发事件,因为在行为 js 中它已检查 if (this._ratingValue != this._currentRating),所以我想重写这个方法而不改变js和构建工具包。我该怎么做,我可以扩展评级控制并覆盖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);
    }
},

【问题讨论】:

    标签: asp.net javascript ajax


    【解决方案1】:

    我已经通过将代码放在上面来解决它

        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>
    

    【讨论】:

    • 我试过这样做,但似乎没有任何效果。除了将此代码添加到我的 aspx 页面之外,我还需要做些什么吗?
    猜你喜欢
    • 2014-02-22
    • 2013-05-22
    • 1970-01-01
    • 2011-06-19
    • 2010-11-22
    • 2011-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多