1

I've seen this code in the Sencha Touch documentation. If autoCreate was set false what would happen to the infopanel view? Not sure I understand why autoCreate has to be specified. Could it not do this behind the scenes anyway if the object type ref is used instead of the simple type?

refs: {
    main: '#mainTabPanel',
    loginButton: '#loginWindow button[action=login]',

    infoPanel: {
        selector: 'infopanel',
        xtype: 'infopanel',
        autoCreate: true
    }
}
jaffa
  • 26,770
  • 50
  • 178
  • 289

1 Answers1

1

I just replaced a few lines of code in one of my project to use autoCreate.

This is what I used to do :

refs: {
  detailsView: 'detailsview'
},

...

var view = (!this.getDetailsView()) ? Ext.create('App.view.DetailsView') : this.getDetailsView();
nav.push(view);

I used to check if the view was created by calling the getter this.getDetailsView(). If it was not created, I created it, otherwise I just used the reference to it.

Now, I'm using autoCreate and this is what I do :

refs: {
  detailsView: {
    selector: 'detailsview',
    xtype: 'detailsview',
    autoCreate: true
  }
},

...

var view = this.getDetailsView()
nav.push(view);

Calling the getter this.getDetailsView() will either use the reference to the already created component or create it.

Hope this helps

Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121