作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经尝试让它工作了很长一段时间,但我仍然无法找到解决方案,除了在 View 中的监听器中添加 afterrender。但我希望 Controller 处理它。
有没有人知道我如何解决这个问题?
这是我目前文件中的内容
http://pastie.org/2751446
controller/App.js
Ext.define('HD.controller.App', {
extend: 'Ext.app.Controller'
,views: [
'core.Header',
'core.Navigation',
'core.Content'
]
,init: function() {
this.control({
'navigation a[id=tab1]': {
click: this.newTab
}
})
}
,newTab: function() {
console.log('Tab 1 should be loaded now');
}
});
Ext.define('HD.view.core.Navigation', {
extend: 'Ext.panel.Panel'
,name: 'navigation'
,alias: 'widget.navigation'
,layout: 'accordion'
,region: 'west'
,width: 200
,title: 'Navigation'
,collapsible: true
,items: [
{
title: 'Title 1'
,html: '<a id="tab1" style="cursor:pointer;">Tab 1</a>'
},
{
title: 'Title 2'
,html: 'Second'
}
]
});
最佳答案
您尝试引用超链接的方式 a
不会工作。
this.control({
'navigation a[id=tab1]': {
click: this.newTab
}
})
var controller = this;
controller.control({
'navigation': {
afterrender: function() {
Ext.get('tab1').on('click', function() {
controller.newTab();
});
}
}
})
关于ExtJS Controller 在超链接点击时触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7879402/
我是一名优秀的程序员,十分优秀!