Search code examples
eventsextjssencha-touchsencha-touch-2

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);


Solution

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

    UPDATE

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