Created
March 15, 2012 16:50
-
-
Save mteece/2045236 to your computer and use it in GitHub Desktop.
Ext Controller Button click event firing twice.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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