PDA

View Full Version : close after submit event



billhamawi
19 Jan 2014, 7:41 PM
Hey guys, I am learning extjs and i am having a simple issue which no matter where i look for the answer i can not find it.
So the issue is i want to submit when button clicked and then close but it fires the close before the submit and i get store data undefined.
Any help is appreciated.

if [email protected]
saveButtonandClose=
{
text: 'Save & Close'
scope : me
#hidden : #me.readOnly
name: "saveRequestButton"
id:"saveRequestBtn"
type: submit
handler:"click":()->
me.close() <-will close but will fire before submit event i need it to submit and then close.

}

Gary Schlosberg
19 Jan 2014, 8:41 PM
Does it work if you use the handler as in the example on this page?
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.Panel

You could close the page if successful, return a message if not.

billhamawi
19 Jan 2014, 9:24 PM
saveButtonandClose= { text: 'Save & Close'
scope : me
name: "saveRequestButton"
id:"saveRequestBtn"
handler:()->
form = this.up('form').getForm()
if form.isValid
form.submit
success:()-> me.close()
does this look correct to you because i tried this and it is still not closing the window should i try ext.getcmp("someID').close() ???

i actually tried this checked the stack and Uncaught TypeError: Cannot call method 'getForm' of undefined

the funny thing is it is submitting just not god-damn closing.This is driving me up the wall lol

palakurthivishal
20 Jan 2014, 12:36 AM
Hello billhamawi,
I guess you went wrong with the scopes. 'this' in your handler might not be the button component unless you define it in the argument as some variable. Say

handler : function(btn){
btn-- > is your button component
this--> is you class/parent scope
}