PDA

View Full Version : Back button to previous panel



todos27
9 Sep 2011, 4:11 AM
Hello people!

I have a mainPanel which holds an array of panels. On each panel I have a "back" button and this button return to the mainPanel.

But, since the content of my application is getting bigger, I need to add more panels to the children of mainPanel. And I want my "back" button to return to its parent, not to mainPanel as I have implemented my function.

Can anyone suggest me a way to solve this?

Thanks in advance.

var mainPanel = new Ext.Panel({
layout: 'card',
fullscreen: true,
items:[0, 1, 2, 3, 4, 5]
});


var back = function(button, event) {
mainPanel.setActiveItem(0, {type: 'slide', direction: 'right'})
};

SimonFlack
9 Sep 2011, 4:28 AM
What about creating a stack to holde references to the components. When you add a new child you can then add it to the stack. Then just pop them off and activate them.

var back = function(button, event) {
MyHistoryStack.pop() //Get current view off the stack
mainPanel.setActiveItem(MyHistoryStack.pop(), {type: 'slide', direction: 'right'})
};

You will probably have to pop twice. 1st time to get the ref to the view you are on. 2nd time to get the previous view.