I use the following code to set the initial value in the togglefield field and respond to changes in the togglefield field.
I initially disabled togglefield, and then use the (unexpected) behavior that Sencha Touch fires a change event for this togglefield field when it is initialized to enable togglefield.
Note that this should work for both true and false as initial values. If you want to actually disable togglefield initially, you will have to remove the else part.
{ xtype: 'togglefield', title: 'LightSwitch', label: 'Switch Lights', value: false, // initial value listeners: { change: function(slider, thumb, newValue, oldValue) { if (this.isDisabled() == false) { // isEnabled alert('change Togglefield Event triggered'); // do something } else { this.enable(); // enable togglefield } } }, disabled: true, }
source share