Skip to content

Instantly share code, notes, and snippets.

@mteece
Created March 15, 2012 16:50
Show Gist options
  • Save mteece/2045236 to your computer and use it in GitHub Desktop.
Save mteece/2045236 to your computer and use it in GitHub Desktop.
Ext Controller Button click event firing twice.
/* Ext Controller Button click event firing twice.
*
* In our custom routing we lookup the controller by name and fire the init() method.
* We found in doing so when we had components with event listeners firing twice.
* To get around all the duplicate events, rather than say clearing all the event
* listeners in init(), we moved the this.control() into the onLaunch() event.
* As init() is called when your application boots up, and the onLaunch() is
* kind of like init(), but called after the viewport is created.
*/
Ext.define('App.controller.Search', {
extend: 'Ext.app.Controller',
views: [
'transaction.Search'
],
// Called when your application boots.
init: function(app) {
console.log('App.controller.Transaction.Search init');
},
// Like init, but called after the viewport is created.
onLaunch: function(app){
console.log('App.controller.Transaction.Search onLaunch');
this.control({
'transaction-search tool[action=help]': {
click: this.onHelpClick
}
});
},
index: function(){
console.log('App.controller.Transaction.Search index');
this.render('transaction.Search');
},
onHelpClick: function(btn) {
Ext.Msg.show({
title: 'Help Text',
msg: 'Lorem ipsum dolor set amet.',
buttons: Ext.Msg.OK,
icon: Ext.Msg.QUESTION
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment