I'm just starting to pick up Sencha Touch 2 MVC. I have heavy Ext 3 experience, but this is a totally new world.
I can't seem to get very far in building a view. I've taken my code in two directions based on what I've seen on the Internet, and neither works.
Path 1
My app.js:
Ext.application({
name: 'BkAdmin',
views: ['LoginForm'],
launch: function() {
Ext.create('BkAdmin.view.LoginForm');
}
});
My view/LoginForm.js:
Ext.define('BkAdmin.view.LoginForm', {
extend: 'Ext.form.FormPanel',
config: {
fullscreen: true,
initComponent: function() {
alert('yo!');
BkAdmin.view.LoginForm.superclass.initComponent.apply(this, arguments);
}
}
}
);
This loads error-free, and I can even add form items in the config section. However, initComponent() inexplicably never gets called, so the view is utterly inflexible.
Path 2
My app.js:
Ext.application({
name: 'BkAdmin',
views: ['LoginForm'],
launch: function() {
BkAdmin.view.LoginForm = new BkAdmin.view.LoginForm();
}
});
My view/LoginForm.js:
BkAdmin.view.LoginForm = Ext.extend(Ext.form.FormPanel, {
fullscreen: true,
initComponent: function() {
alert('yo!');
BkAdmin.view.LoginForm.superclass.initComponent.apply(this, arguments);
}
});
This flat-out doesn't work. Chrome reports 'Cannot set property 'LoginForm' of undefined'...how on earth did view get undefined? In addition, it says 'The following classes are not declared even if their files have been loaded: 'BkAdmin.view.LoginForm'.' Sure looks declared to me.
Many questions here: what did I do wrong in the above paths? How can I get initComponent() to be called in Path 1, and get Path 2 to work? Which code is quote-unquote better to use?
Thanks!