happyyangyuan
happyyangyuan

Reputation: 179

panel's setTitle() function does not publish to the panel's viewModel

When I call the setTitle function of extjs panel component, the title update immediately, but the viewModel bind to the it does not change!.

Code is as below :

Ext.application({
    name: 'Fiddle',

    launch: function() {


        var textfield = Ext.create('Ext.form.field.Text', {
            itemId: 'textfieldItem',
            fieldLabel: 'fjdks',
            bind: '{customer.name}'
        });

        var panel = Ext.create('Ext.form.Panel', {
            viewModel: {},
            bind: {
                title: '{customer.name}'
            },
            renderTo: Ext.getBody(),
            items: [textfield]

        });

        panel.setTitle('123');
        Ext.Msg.alert('Fiddle', panel.getViewModel().get('customer.name'), function() {
            textfield.setValue('rrrrr');
            Ext.Msg.alert('Fiddle', panel.getViewModel().get('customer.name'));
        });

    }
});

See Sencha fiddle

Upvotes: 1

Views: 504

Answers (1)

Saki
Saki

Reputation: 5856

It is not a two-way binding apparently. You can report it to Sencha as a bug or as a missing feature, however, it is pretty easy to fix it by extending Ext.panel.Panel and implementing applyTitle method that would publish to viewmodel. If you decide for this approach do not forget to call parent applyTitle.

Upvotes: 1

Related Questions