PDA

View Full Version : submit a form using a listener



Kurt001
4 Aug 2011, 9:24 AM
Hi,

I am trying to use the following inside a form

listeners:{
submit: function( myThis, submitResult ) {
alert('submit');
}

But nothing happens when I press enter in Safari (which simulates the standard submit).
What am I doing wrong?

estesbubba
4 Aug 2011, 11:06 AM
Does clicking the button fire the event? I think you actually have to wire the enter key to perform the submit with Touch.

Kurt001
4 Aug 2011, 11:19 AM
The Enter Button fires the standardFormSubmit.
But I would prefer to fire the button handler on Enter.

steve1964
5 Aug 2011, 1:17 AM
Hi, you have to listen on every field in the form, add this listtener to every field:


listeners: {
keyup: function(fld, e){
if (e.browserEvent.keyCode == 13 || e.browserEvent.keyCode == 10) {
e.stopEvent();
fld.fieldEl.dom.blur(); // Hide keyboard
window.scrollTo(0,0); // Scroll to top


yourForm.submit({
waitMsg : {message: 'Submitting...', cls : 'loading'}
});


}
}
}