ducktyped
ducktyped

Reputation: 4504

ExtJS6: Sharing view's viewmodel and controller with modal window

I have a view having form, the view also have a modal window attached. Model window gets opened on click (via handler from controller) like this

this.getView().add({
  xtype: 'settings_modal'
}).show();

Within modal I can not access to viewModel or controller. How could we share view's binding to it child windows

Upvotes: 1

Views: 1026

Answers (1)

fradal83
fradal83

Reputation: 2022

I have succesfully passed the viewController, just adding it to the configuration, like this:

this.getView().add({
  xtype: 'settings_modal',
  viewController: this
}).show();

However, I think it's better to add the modal to the view definition, hidden by default.

Ext.define('My.view.form', {
...
    items[
    ...
    ,{
        xtype: 'settings_modal',
        hidden: true
    }]
});

This way, the viewModel and controller will be shared by default.

Upvotes: 2

Related Questions