bagusflyer
29 Dec 2011, 7:24 AM
I encountered another problem: the panel I created in my controller doesn't show up. Here is my code:
app.js
Ext.Loader.setConfig({
enabled : true,
paths : {
Override : 'overrides'
}
});
Ext.application({
name: 'App',
autoCreateViewport: true,
models: ['User'],
stores: ['MyProfile'],
controllers: ['Root'],
init: function () {
console.log('app initialize');
},
launch: function() {
console.log('app launch');
}
});
Root.js (controller)
Ext.define('App.controller.Root', {
extend: 'Ext.app.Controller',
stores: ['MyProfile'],
init: function() {
console.log('init root controller');
},
onLaunch: function() {
console.log('onLaunch root controller');
var store = App.store.myProfile;
if ( store )
{
// store.load();
if ( store.first() )
{
// do something
return;
}
}
this.showProfile();
},
showProfile: function() {
console.log('Show user profile');
var panel = Ext.create('Ext.Panel', {
html: 'This is my panel'
});
Ext.Viewport.add(panel);
},
}
});
Viewport.js
Ext.define('App.view.Viewport', {
extend : 'Ext.Panel',
xtype : 'app-viewport',
config : {
fullscreen : true,
layout : 'card',
items:
[{
xtype : 'toolbar',
docked : 'top',
title : APPNAME,
items :
[{
ui : 'action',
itemId : LEFTBTN,
},{xtype:'spacer'},
{
ui : 'action',
itemId : RIGHTBTN,
}]
}]
}
});
The showProfile function is called but the new panel is never show up.Can anybody help? What's wrong with my code? Thanks.
I found the most difficult part of Sencha touch is the relationship of different element. It's too flexible. For example, you create a panel, you can use Ext.create, or something like define then config: {} etc. I've spent 1 week at 1.1 and now at 2.0 and I got totally no clue at all.
app.js
Ext.Loader.setConfig({
enabled : true,
paths : {
Override : 'overrides'
}
});
Ext.application({
name: 'App',
autoCreateViewport: true,
models: ['User'],
stores: ['MyProfile'],
controllers: ['Root'],
init: function () {
console.log('app initialize');
},
launch: function() {
console.log('app launch');
}
});
Root.js (controller)
Ext.define('App.controller.Root', {
extend: 'Ext.app.Controller',
stores: ['MyProfile'],
init: function() {
console.log('init root controller');
},
onLaunch: function() {
console.log('onLaunch root controller');
var store = App.store.myProfile;
if ( store )
{
// store.load();
if ( store.first() )
{
// do something
return;
}
}
this.showProfile();
},
showProfile: function() {
console.log('Show user profile');
var panel = Ext.create('Ext.Panel', {
html: 'This is my panel'
});
Ext.Viewport.add(panel);
},
}
});
Viewport.js
Ext.define('App.view.Viewport', {
extend : 'Ext.Panel',
xtype : 'app-viewport',
config : {
fullscreen : true,
layout : 'card',
items:
[{
xtype : 'toolbar',
docked : 'top',
title : APPNAME,
items :
[{
ui : 'action',
itemId : LEFTBTN,
},{xtype:'spacer'},
{
ui : 'action',
itemId : RIGHTBTN,
}]
}]
}
});
The showProfile function is called but the new panel is never show up.Can anybody help? What's wrong with my code? Thanks.
I found the most difficult part of Sencha touch is the relationship of different element. It's too flexible. For example, you create a panel, you can use Ext.create, or something like define then config: {} etc. I've spent 1 week at 1.1 and now at 2.0 and I got totally no clue at all.