【发布时间】:2012-02-28 12:06:15
【问题描述】:
我刚开始使用 Sencha 框架 2.x。这是我的应用程序:
app/app.js
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: 'App',
controllers: ['Generators'],
models: [],
stores: [],
views: ['Main', 'Generator'],
launch: function() {
Ext.create('App.view.Main');
}
});
app/view/Main.js
Ext.define('App.view.Main', {
extend: 'Ext.NavigationView',
requires: [
'App.view.Generator'
],
config: {
fullscreen: true,
items: [
{
xtype: 'generatorview'
}
]
}
});
app/view/Generator.js
Ext.define('App.view.Generator', {
extend: 'Ext.Container',
xtype: 'generatorview',
id: 'generator',
config: {
layout: 'vbox',
items: [
{
xtype: 'panel',
html: 'My message: <a id="xxxSet">Set</a> :: <span id="xxxMsg">...</span>',
flex: 1
},
{
dock: 'bottom',
xtype: 'toolbar',
items: []
}
]
}
});
app/controller/Generator.js
Ext.define('App.controller.Generators', {
extend: 'Ext.app.Controller',
config: {
refs: {}
},
init: function() {
this.control({
'#xxxSet': { // QUESTION1
tap: 'setMyMessage'
}
});
},
setMyMessage: function() {
'#xxxMsg'.html('Set this message'); // QUESTION2
}
});
如您所见,我在最后一部分(控制器)提出了问题。
- QUESTION1:如何为元素设置点击功能 (#xxxSet) 在视图中定义为 HTML 内容。
- 问题 2:如何设置 将视图中定义为 HTML 的元素 (#xxxMsg) 发送消息 内容。
xxxSet = 按钮的 ID
xxxMsg = 消息持有者的 id
谢谢!
【问题讨论】:
标签: javascript model-view-controller mobile extjs sencha-touch-2