PDA

View Full Version : Auto-create 'Back' button



BenMajor
15 Mar 2011, 2:45 PM
I don't know if this question has already been asked, but I tried the search function without much luck.

My question is simple really - is there an easy way to have Sencha Touch automatically create a 'back' button when switching Panels? At the moment, I'm having to hard card it onto the target Panel using the following code:


items: [ {
xtype: 'button',
ui: 'back',
text: 'Back',
handler: function() {
rootPanel.setActiveItem(screens['main'], { type: 'swipe', direction: 'right' }
}
} ]

Obviously since the animation is hard carded into the button, if I change the animation on the show function, I also need to change it to the reverse on the back button. This is a feature other frameworks (such as jQuery Mobile) have already, so I'm sure it must be there somewhere? :-?

Any help would be most gratefully received,
Ben.

zonathen
11 Oct 2011, 6:19 PM
Hello, I'm strugging with this as well.. I believe the only way to get a build in back button is to use a treestore to hold the cards like so (taken from the nelstrom toolbars and tabs demo):



ToolbarDemo.morestore = new Ext.data.TreeStore({
model: 'ListItem',
root: {
items: [{
text: 'About',
card: {xtype: 'aboutcard'},
leaf: true
},
{
text: 'Bookmarks',
card: {xtype: 'bookmarkcard'},
leaf: true
}],
},
proxy: {
type: 'ajax',
reader: {
type: 'tree',
root: 'items'
}
}
});