From 1f8a1f7381b76c4c2b43437ebc7e30100a4bb36d Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 20 Nov 2013 21:32:35 +0100 Subject: Fixed DefaultButton --- .../Web/Javascripts/source/prado/controls/controls.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/Javascripts/source/prado/controls/controls.js b/framework/Web/Javascripts/source/prado/controls/controls.js index 619e924b..b4d5653e 100644 --- a/framework/Web/Javascripts/source/prado/controls/controls.js +++ b/framework/Web/Javascripts/source/prado/controls/controls.js @@ -413,24 +413,24 @@ Prado.WebUI.DefaultButton = jQuery.klass(Prado.WebUI.Control, onInit : function(options) { this.options = options; - this.observe(options['Panel'], "keydown", jQuery.proxy(this.triggerEvent,this)); + this.observe(jQuery('#'+options['Panel']), "keydown", jQuery.proxy(this.triggerEvent,this)); }, - triggerEvent : function(ev, target) + triggerEvent : function(ev) { - var enterPressed = Event.keyCode(ev) == Event.KEY_RETURN; - var isTextArea = Event.element(ev).tagName.toLowerCase() == "textarea"; - var isHyperLink = Event.element(ev).tagName.toLowerCase() == "a" && Event.element(ev).hasAttribute("href"); - var isValidButton = Event.element(ev).tagName.toLowerCase() == "input" && Event.element(ev).type.toLowerCase() == "submit"; + var enterPressed = ev.keyCode == 13; + var isTextArea = ev.target.tagName.toLowerCase() == "textarea"; + var isHyperLink = ev.target.tagName.toLowerCase() == "a" && ev.target.hasAttribute("href"); + var isValidButton = ev.target.tagName.toLowerCase() == "input" && ev.target.type.toLowerCase() == "submit"; if(enterPressed && !isTextArea && !isValidButton && !isHyperLink) { - var defaultButton = $(this.options['Target']); + var defaultButton = $('#'+this.options['Target']); if(defaultButton) { this.triggered = true; - Event.fireEvent(defaultButton, this.options['Event']); - Event.stop(ev); + defaultButton.trigger(this.options['Event']); + ev.preventDefault(); } } } -- cgit v1.2.3