Completed
Last Updated: 03 Sep 2013 13:29 by Michael
ADMIN
Danail Vasilev
Created on: 06 Aug 2013 13:33
Category: Button
Type: Bug Report
2
FIX duplicate requests of RadButton when a form's defaultbutton property is set
RadButton peforms duplicate requests when:

- A RadButton exists on the page and the form is submitted when a text box is focused and enter key is hit.
- the defaultbutton property of the form is set to the id of the RadButton

For the time being the following functions' override can be used:

        <script type="text/javascript">
            Telerik.Web.UI.RadButton.prototype._isButtonActiveElement = function (eventTarget) {
                var doc = eventTarget && eventTarget.ownerDocument ? eventTarget.ownerDocument : document;
                var activeElement = doc.activeElement;
                if (!activeElement)
                    return false;
                if (activeElement === this.get_element() || $telerik.$.contains(this.get_element(), activeElement))
                    return true;
                return false;
            }

            var originalMouseClickHandler = Telerik.Web.UI.RadButton.prototype._mouseClickHandler;
            Telerik.Web.UI.RadButton.prototype._mouseClickHandler = function (args) {
                if (!this.get_enabled() || this.get_readOnly()) {
                    $telerik.cancelRawEvent(args.rawEvent);
                    return false;
                }

                var eventTarget = args.target ? args.target : args.srcElement;
                if (eventTarget === this.get_element() && !this._isButtonActiveElement(eventTarget) && !$telerik.isTouchDevice) {
                    $telerik.cancelRawEvent(args.rawEvent);
                    this.focus();
                    return false;
                }
                originalMouseClickHandler.call(this, args);
            }
        </script>

The workaround must be placed after the declaration of the RadButton, in order to take effect.
1 comment
Michael
Posted on: 06 Aug 2013 13:51
To viewers of this bug in the feedback portal:  If you use RadButton, and care about the performance of your application, you should vote for this one.  Thanks...