Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set value of numberfield without firing "change" event in Sencha Touch

I have a numberfield and a list in Sencha Touch. When I click on an item in the list, I am doing an AJAX request to send data to the server. However, if there is data in the numberfield, I want to clear that when the list is clicked on.

I have no problem doing this (I am setting the value to a blank string), however, the change event is fired on the numberfield. This causes another AJAX request to run which doesn't need to. Is there any way to clear a numberfield WITHOUT firing the change event? SuspendEvents does not work as clearing the numberfield requires an event.

Any thoughts or suggestions? Thanks!

Code lines that I have tried:

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

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

like image 200
bnrq Avatar asked Jun 04 '13 15:06

bnrq


2 Answers

Do suspendEvents(), update your numberfield and then do resumeEvents()

UPDATE

var control = me.getWhatScreen().down(...);
control.suspendEvents();
control.setValue('');
control.resumeEvents(false);
like image 176
sha Avatar answered Oct 12 '22 23:10

sha


UPDATE for Sencha Touch 2.4

the correct sequence is

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

resumeEvents takes the boolean parameter discardQueuedEvents

like image 34
yann1s Avatar answered Oct 12 '22 23:10

yann1s