我在主视图中声明包含。那么如何在控制器中访问。这里我有democontainer和demopanel。那么如何访问它。
Ext.define('MyApp.view.Main', {
extend: 'Ext.Panel',
alias: 'widget.mainpage',
config: {
width: 710,
margin: '10px auto 0',
itemId: 'democontainer',
layout: {
type: 'hbox'
},
items: [
{
xtype:'container',
cls:'wholeMenuWrap',
margin: '65px 0 0 0',
width: 175,
items:[
....and
{
xtype: 'homepage',
cls:'homepage-wrap',
itemId: 'demopanel',
layout: {
type: 'fit'
}
},
{
xtype:'container',
layout: 'vbox',
margin: '65px 0 0 0',
width: 185,
items:[
{
xtype: 'titlebar',
cls:'roundedToolbar',
我想像这样访问控制器,但我无法访问它。
config: {
main:this,
profile: Ext.os.deviceType.toLowerCase(),
refs:{
myContainer: 'mainpage',
},
control: {
'mainpage': {
activate: 'onActivate',
itemtap: 'onItemTap',
},
'mainpage textfield[itemId=searchBox]' : {
//clear the input text box
clearicontap : 'onClearSearch',
//on every key stroke
keyup: 'onSearchKeyUp'
},
...........
onSearchKeyUp: function(searchField) {
var container = this.up('#democontainer');
var panel = container.down('#demopanel');
panel.removeInnerAt(0);
var submitWordBySearch = { xtype: 'searchplusfav' };
panel.insert(0, submitWordBySearch);
我收到此错误:
Uncaught TypeError: Object [object global] has no method 'up'
任何人请帮帮我。
我添加了新代码:
refs:{
myContainer: 'mainpage',
demoContainer2: '#democontainer', //same as demoContainer1
demoContainer3:'#demopanel'
},
...-------------
onSearchKeyUp: function(searchField) {
var container = this.getDemoContainer2();
var panel = container.getDemoContainer3();
panel.removeInnerAt(0);
var submitWordBySearch = { xtype: 'searchplusfav' };
panel.insert(0, submitWordBySearch);
得到错误:
Uncaught TypeError: Object [object global] has no method 'demoContainer2'
工作代码:
onKeySubmitTap: function(dataview, index, target, record, e, options)
{
var container = dataview.up('#democontainer');
var panel = container.down('#demopanel');
panel.removeInnerAt(0);
var submitWordBySearch = { xtype: 'categorywordsdisplay' };
panel.insert(0, submitWordBySearch);
}