2
votes

I'm using the navigation view in Sencha Touch 2 to provide view navigation in my app.

Currently I'm using the approach of creating a view object (say "VOCABI.view.Search", with xtype "searchview") in the launch method of the controller and referring to it by including the following in controller config:

refs: {
    searchView: 'searchview'
}

When I want to present the search view, I push it into the navigation view like this:

navView = this.getNavView();                  // Defined
navView.push([this.getSearchView()]);         // Defined by refs

The problem is when the user is done with the search and presses the back button on the view, the searchView seems to be destroyed so that it causes trouble the next time the user wants to search something since the getSearchView() method now returns null.

Is this the default behavior of navigation view that it destroys the popped view when the method pop() is called?

If so, would this be a bad workaround to create the search view every time you present it? Like

Ext.create("VOCABI.view.Search");
this.getNavView().push([this.getSearchView()]); 

Thanks so much for your help!

2

2 Answers

3
votes

Once popped, it is default in Sencha Touch 2.0 that NavigatioView will destroy that child component. So, for your case, you can just use this without any worry:

navView.push({
   xtype : 'searchview'
}); 

You can force to not destroying the child component of a NavigationView. However, for your case, it seems destroying will be a good practice anyway.

5
votes

you have to add config of navigationview

autoDestory:false

because of this your search view is not destory on pop event of navigation view