-
28 Mar 2012 8:55 PM #1
beforesubmit confirm message box
beforesubmit confirm message box
Hi,
I'm making a contact form in sencha and before sending the form I want it to ask user confirmation to send it or no. For this I tap 'beforesubmit' event like this:
and here is confirmSend function code:Code:.... ...... xtype: 'formpanel', title: 'Contact', iconCls: 'user', url: 'sendmail.php', listeners: { beforesubmit: confirmSend }, layout: 'vbox', cls: 'forms', ........ ..... ...
Now I don't see this confirm message when I click on Submit. But I know that the form listeners is working and it does call the confirmSend function. When I just put a Alert() in confirmSend, it shows that message. Like this:Code:function confirmSend(panel, vals, opts) { Ext.Msg.confirm("Confirmation", "Are you sure you want to send this info?", function(btn){ if (btn == 'Yes'){ alert('go ahead'); } else { alert('abort'); } }); }
Can anybody tell me what I'm doing wrong.Code:function confirmSend(panel, vals, opts) { alert('hello'); /*Ext.Msg.confirm("Confirmation", "Are you sure you want to send this info?", function(btn){ if (btn == 'Yes'){ alert('go ahead'); } else { alert('abort'); } });*/ }
-
29 Mar 2012 4:47 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
beforesubmit should be preventable so you should return false like so:
However, trying this and it does not prevent the submitting so I am going to report as a bug.Code:listeners : { beforesubmit : function() { console.log('fired'); Ext.Msg.confirm("Confirmation", "Are you sure you want to send this info?", function(btn){ if (btn === 'yes'){ console.log('go ahead'); } else { console.log('abort'); } }); return false; } }
Full testcase:
Code:new Ext.form.Panel({ fullscreen : true, url : 'data/json.json', items : [ { xtype : 'textfield', label : 'Test', name : 'test' }, { xtype : 'button', text : 'Submit', handler : function(button) { var form = button.up('formpanel'); form.submit({ success : function() { console.log('submit handled!'); } }); } } ], listeners : { beforesubmit : function() { console.log('fired'); Ext.Msg.confirm("Confirmation", "Are you sure you want to send this info?", function(btn){ if (btn === 'yes'){ console.log('go ahead'); } else { console.log('abort'); } }); return false; } } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
29 Mar 2012 1:18 PM #3
All events are fired *after* the event, just like 1.x. It just so happens that this event doesn't really make sense to be fired *after*.
We will fix this hopefully before the next release, but until then, you can change the 'order' to be before.
Code:listeners: { order: 'before', beforesubmit: function() { // ... } }Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
30 Mar 2012 12:13 AM #4
Thanks mitchellsimoens and rdougan
The confirmation message is now showing up when I put order: 'before' but now when I return true when user taps on Yes, the form is not getting submitted. What is wrong?
Here is the code:
Code:function confirmSend(panel, vals, opts) { Ext.Msg.confirm("Confirmation", "Are you sure you want to send this info?", function(btn){ if (btn == 'yes') { return true; } else { return false; } }); return false; }
-
21 May 2012 8:26 AM #5
Bug Fixed?
Bug Fixed?
Is this bug fixed? or any work around available?
-
21 May 2012 8:43 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
12 Dec 2012 10:27 AM #7
Isn't this really a bug with the Ext.mixin.Observable#fireAction method?
The documentation says...
"Fires the specified event with the passed parameters and execute a function (action) at the end if there are no listeners that return false."
Shouldn't you just make the default order for functions passed into the fireAction method be "after"?
Code:fireAction: function(eventName, args, fn, scope, options, order) { var fnType = typeof fn, action; if (args === undefined) { args = []; } if (fnType != 'undefined') { action = { fn: fn, isLateBinding: fnType == 'string', scope: scope || this, options: options || {}, order: order || 'after' }; } return this.doFireEvent(eventName, args, action); }
-
18 Feb 2013 3:40 PM #8
Same issue, different scenario
Same issue, different scenario
Versions: 2.2.0-alpha (and 2.1.1)
Browser: Chrome 24 (Win8 / Desktop)
Attachment: Full test case
The fireAction function (3rd parameter 'fn') is called BEFORE controller's bound slots if identifier selectors are used in the 'control' config. If xtype selectors are used, fireAction() works as expected (and the action function is called AFTER). Same workaround, explicitly use this.fireAction('click', [ this ], '_doClick', this, {}, 'after').
Test case (code extracted from the full test case in attachment):
App.view.Main
App.controller.MainPHP Code:[...]
_fireAction: function() {
console.log('----\n_fireAction (before)');
this.fireAction('click', [ this ], '_doClick');
console.log('_fireAction (after)\n----');
},
_doClick: function() {
console.log('_doClick');
}
[...]
Console outputPHP Code:[...]
config: {
control: {
// [OK] _onClick is called BEFORE action function
//'main': { click: '_onClick' },
// [FAILED] _onClick is called AFTER action function,
// so we can't prevent action execution.
'#app-main': { click: '_onClick' }
}
},
_onClick: function() {
console.log('_onClick (return false)');
return false;
}
[...]
Code:_fireAction (before) _doClick _onClick (return false) _fireAction (after)
You found a bug! We've classified it as
TOUCH-2622
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote