Ajax control toolkit Rating Control - переопределить RatingBehavior.js - PullRequest
2 голосов
/ 10 февраля 2009

Контроль рейтинга в наборе инструментов управления ajax не будет вызывать событие, если пользователь нажимает на текущую звезду рейтинга из-за поведения js, у которого есть проверка if (this._ratingValue! = this._currentRating), поэтому я хочу переопределить этот метод без изменения js и построения takeit. Как я могу это сделать, могу ли я расширить контроль над рейтингом и переопределить 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);
        }
    },

1 Ответ

3 голосов
/ 10 февраля 2009

Я решил это, поместив код чуть выше

    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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...