Skip to content

Instantly share code, notes, and snippets.

@mcollina
Created May 17, 2011 15:24
Show Gist options
  • Save mcollina/976679 to your computer and use it in GitHub Desktop.
Save mcollina/976679 to your computer and use it in GitHub Desktop.
Sencha Touch Back Button Plugin
BackButton = Ext.extend(Ext.Button, {
ui: 'back',
text: 'Back',
hidden: true,
id: 'back',
handler: function() {
var dispatchOptions = this.backStack.pop();
Ext.dispatch(dispatchOptions);
if(this.backStack.length == 0) {
this.hide();
}
},
backStack: [],
addToBackStack: function(dispatchOptions) {
var found = false;
this.backStack.forEach(function(el) {
found = found || (Ext.encode(el) == Ext.encode(dispatchOptions));
});
if (!found) {
this.backStack.push(dispatchOptions);
}
this.show();
},
clearBackStack: function() {
this.backStack = [];
this.hide();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment