DewinDell
DewinDell

Reputation: 1028

Updating button attribute in a view from controller - Sencha Touch

I have a simple form in a view and I have a field that looks like this:

xtype: 'numberfield',
label: 'Number',
name: 'num',
disabled: true

This field is in a 'formpanel'. I am trying to set disabled to false when the form button is pressed (enable the field).

Now, there is a button in the form that triggers a function in the view (onButtonTap) and fires a function in the controller (enableField) and sends the panel and values to it:

onButtonTap: function(button, e, eOpts) {
   var panel = button.up('formpanel')
   var values = panel.getValues();      
   panel.parent.fireEvent('enableField', panel, values);
}

And in my controller this is enableField:

enableField: function(panel, values) {
   panel.config.items[0].items[1].disabled = false;
}   

I am sure my controller works fine and the function enableField is actually fired, but nothing happens to the button and it stays disabled..

What am I missing?

Upvotes: 0

Views: 482

Answers (1)

Sujata Chanda
Sujata Chanda

Reputation: 3395

In the controller(within refs) add the following code to get the 'numberfield' to be enabled:

refs{
     numberField: 'numberfield[name="num"]'
}

And on button tap enable the field by ths:-

onButtonTap: function(button, e, eOpts) {

        this.getNumberField().enable();

}

Upvotes: 1

Related Questions