Reputation: 2279
I am facing an issue with my controllers refs
and the returned object being invalid. And by invalid it returning me an object that says it has not been rendered even though i am in the process of using it.
In my controller I have a ref defined as the following.
refs : [ {
ref : 'selectDeltaView',
selector : '[itemId=selectDeltaView]'
}]
and later in my controller I access this view using the created accessor
this.getSelectDeltaView()
What is strange is that the first time this view is presented, inside of an Ext.Window
it works just fine. However, on the second launch the view I get back is not rendered.
this.getSeletDeltaView().rendered === false
Reading the documentation over at Sencha it seems that this simply passes my selector to the Ext.ComponentQuery.query
function. However, if I call Ext.ComponentQuery.query('[itemId=selectDeltaView]')
I get an array with a single element of which rendered is true.
Am i missing something? Why is my controllers reference returning me invalid data.
Update
Some additional details not mentioned in the original post. My initial assumption was that my view was not being destroyed. However, I have log statements in my ondestory
and beforedestory
events and can confirm that on closing the window my view is being destroyed.
What is the most confusing is that if refs simply use Ext.ComponentQuery.query
, why does Ext.ComponentQuery.query
only return one view when the window is re-opened and it returns the correct view. I understand from the question below that refs will catch the view, but that view no longer exist.. or shouldn't.. If the view is destroyed, can I force the controller to clear its catch?
Upvotes: 0
Views: 69
Reputation: 19895
The controllers reference is cached after the first evaluation.
What happens is this:
getSeletDeltaView()
finds that view, and stores a reference to it in the reference lookup cache.getSeletDeltaView()
finds the first view, that is no longer rendered, but still exists, because it was not destroyed. You cannot use this reference, because it point to the wrong view.Solution:
Make sure to destroy()
your view, when you hide it. You can also use autoDestroy
as a property. Usually, autoDestroy
is true by default.
Upvotes: 1