Sets the value of a number field without triggering a β€œchange” event in Sencha Touch

I have a number field and a list in Sencha Touch. When I click on an item in the list, I make an AJAX request to send data to the server. However, if there is data in the number field, I want to clear it when the list is clicked.

I have no problem with this (I set the value to an empty string), however the change event is fired on the number field. This raises another AJAX request that is not needed. Is there a way to clear the number field without involving the change event? SuspendEvents does not work because an event is required to clear the number field.

Any thoughts or suggestions? Thanks!

Code lines I tried:

suspendEvents(); me.getWhatScreen().down('numberfield[name=caseNumber]').setValue(''); resumeEvents(true);

me.suspendEvents(); me.getWhatScreen().down('numberfield[name=caseNumber]').setValue(''); me.resumeEvents(true);

+7
source share
2 answers

Make suspendEvents() , update your field and then resumeEvents()

UPDATE

 var control = me.getWhatScreen().down(...); control.suspendEvents(); control.setValue(''); control.resumeEvents(false); 
+22
source

UPDATE for Sencha Touch 2.4

correct sequence

 var control = me.getWhatScreen().down(...); control.suspendEvents(); control.setValue(''); control.resumeEvents(true); 

resumeEvents takes a boolean parameter discardQueuedEvents

+3
source

All Articles