PDA

View Full Version : Reset form items doesn't work



maxritti
3 Jun 2012, 12:03 AM
Hello all,

in my application i use following code for a form.

http://dev.sencha.com/deploy/ext-4.0.0/examples/form/contact-form.html

In this example if user enters some information in the fields, clicks on cancel and reopen the form the items are clear.
But in my application after entering some information canceling the operation and reopen the window user can see old values.

Can anybody tell me why the form in my application is not blank?
Or what is the parameter in the example for resetting the items?

maxritti
3 Jun 2012, 12:28 AM
One more information



// In a real application, this would submit the form to the configured url
// this.up('form').getForm().submit();
this.up('form').getForm().reset();
this.up('window').hide();

In my application i changed the code to this one:



if (this.up('form').getForm().isValid()) {
this.up('form').getForm().submit({
waitMsg : 'Save...',
success : function() {
win.hide();
},
failure : function() {
...


But if i integrate this line in my code:

this.up('form').getForm().reset();

i get the error message

this.up is not a function

scottmartin
3 Jun 2012, 8:15 AM
Have you evaluated 'this' to make sure your scope is correct?

Scott.

maxritti
3 Jun 2012, 8:56 AM
I thought that i can use this.up('form') in the submit method because there "this" is valid in this scope.
But what can i use i instead of "this.up('form')"?


this.up('form').getForm().submit({
waitMsg : 'Save...',
success : function() {
this.up('form').getForm().reset();
win.hide();

scottmartin
3 Jun 2012, 9:23 AM
You have direct access to the form if you include the params:

success: function(form, action) { .. }

Scott.

maxritti
3 Jun 2012, 10:25 AM
Cool, thank you very much.