tags:

views:

32

answers:

1

I have Ext.form.FieldSet with some fields in it. It looks like:

var register_options = new Ext.form.FieldSet({
    autoHeight: true,
    title: 'My Title',
    checkboxToggle: true,
    checkboxName: 'register_options',
    items: [item1, item2, item3]
});

When my fieldset checkbox is unchecked (fieldset is collapsed) i don't want submit any of its fields (item1, item2...).

I can do this by adding some listeners and disabling fields:

listeners: {
    collapse: function(p) {
        p.items.each(function(i) {
            i.disable();
        },
        this);
    },
    expand: function(p) {
        p.items.each(function(i) {
            i.enable();
        },
        this);
    }
}

Is it proper way, how can i do this better?

A: 

I don't see anything wrong with your code as long as it works. An alternate that is not as elegant would involve using the cascade function to drill down into the containers.

It Grunt