如何以编程方式触发面板上的事件?
我有以下菜单。
用户单击面板的标题,中间的区域会发生变化,这是有效的。
但是,我总是想以编程方式单击面板,例如,以便我可以在打开面板的文本中创建超链接,就像用户单击它们一样。
如何以编程方式触发手风琴菜单中面板上的单击事件,如下所示:
Ext.select('span#internal_link_001').on('click', function() {
Ext.getCmp('panelApplication').trigger('click'); //error "trigger is not a function"
});
手风琴菜单代码:
Ext.onReady(function(){
menuItemStart = new Ext.Panel({
id: 'panelStart',
title: 'Start',
html: 'This is the start menu item.',
cls:'menuItem'
});
menuItemApplication = new Ext.Panel({
id: 'panelApplication',
title: 'Application',
html: 'this is the application page',
cls:'menuItem'
});
menuItemModules = new Ext.Panel({
id: 'panelModules',
title: 'Modules',
layout: 'card',
html: 'this is the modules page',
cls:'menuItem'
});
menuItemSettings = new Ext.Panel({
id: 'panelSettings',
title: 'Settings',
layout: 'card',
html: 'this is the settings page',
cls:'menuItem'
});
var regionMenu = new Ext.Panel({
region:'west',
split:true,
width: 210,
layout:'accordion',
layoutConfig:{
animate:true
},
items: [ menuItemStart, menuItemApplication, menuItemModules, menuItemSettings ]
});
....
I have the following according menu.
The user clicks on the headers of the panels and a region in the middle changes, that works.
However, I always want to programmatically click the panels, e.g. so that I can create hyperlinks in the text which open up panels, just as if the user clicked on them.
How can I trigger an event click programmatically on a panel in my accordion menu, something like this:
Ext.select('span#internal_link_001').on('click', function() {
Ext.getCmp('panelApplication').trigger('click'); //error "trigger is not a function"
});
Accordion menu code:
Ext.onReady(function(){
menuItemStart = new Ext.Panel({
id: 'panelStart',
title: 'Start',
html: 'This is the start menu item.',
cls:'menuItem'
});
menuItemApplication = new Ext.Panel({
id: 'panelApplication',
title: 'Application',
html: 'this is the application page',
cls:'menuItem'
});
menuItemModules = new Ext.Panel({
id: 'panelModules',
title: 'Modules',
layout: 'card',
html: 'this is the modules page',
cls:'menuItem'
});
menuItemSettings = new Ext.Panel({
id: 'panelSettings',
title: 'Settings',
layout: 'card',
html: 'this is the settings page',
cls:'menuItem'
});
var regionMenu = new Ext.Panel({
region:'west',
split:true,
width: 210,
layout:'accordion',
layoutConfig:{
animate:true
},
items: [ menuItemStart, menuItemApplication, menuItemModules, menuItemSettings ]
});
....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不使用适当的组件功能:
Why don't you use the appropriate component features: