Gale
Gale

Reputation: 399

checked state in Sencha Touch

I can get checkbox state with:

var c = Ext.getCmp("my_checkbox").checked;

but I can get checkbox changes ?

is there something i need to code in to make visual changes?

Upvotes: 1

Views: 5272

Answers (1)

rdougan
rdougan

Reputation: 7225

To do this in Sencha Touch, you will need to add event listeners to the Ext.form.Checkbox component. You can do this using the following code:

new Ext.form.Checkbox({
    id: 'my_checkbox',
    listeners: {
        check: function() {
            alert('I was checked!');
        },
        uncheck: function() {
            alert('I was unchecked!');
        }
    }
});

In the future, it is best to post your questions on the Sencha Forums, as you will get a faster response there.

Update Updated answer for your comment:

var filter = {
    id: 'filter',
    items: [
        {
            xtype: 'fieldset',
            items: [
                {
                    type: 'checkboxfield',
                    name: 'city[1]',
                    label: 'city',
                    id: 'city1',
                    checked: true,
                    listeners: {
                        check: function() {
                            //do something
                        },
                        uncheck: function() {
                            //do something
                        }
                    }
                }
            ] // END items
        }
    ] // END items
}; 

Upvotes: 3

Related Questions