PDA

View Full Version : ViewControllers and beforeInit



Turonah
28 May 2014, 5:42 AM
After reading about ViewControllers in the Sencha Blog post about them (http://www.sencha.com/blog/using-viewcontrollers-in-ext-js-5/), I tried using the beforeInit function to initialise some variables, but found that the function was never called. Has anyone else tried this? Is this functionality broken, or have I done something wrong?

Here's the code I'm using (fairly straight-forward):

Ext.define('MyApp.view.MainController', {
extend: 'Ext.app.ViewController',
alias: 'controller.main',

beforeInit: function () {
console.log('beforeInit - loading css files');
},
init: function () {
console.log('init - doing stuff here now');
}
});


In the application's launch function, I create the main view which uses the above controller. I see the console entry for the init function, but nothing for beforeInit. Thoughts?

LesJ
28 May 2014, 6:24 AM
Probably this method was added after the first beta.

Turonah
6 Jun 2014, 5:49 AM
Thanks. I'll try again with a later version, but for now I've figured out a way of getting things working without it.