【发布时间】:2022-08-19 00:07:04
【问题描述】:
我想检测工具栏上的点击,或者工具栏的焦点。
用例是从具有工具栏的 LiveSearchGrid 中提取的,在代码中可以看到。提供的代码渲染良好,但没有检测到点击、焦点或其他任何内容。根本不值一提。
见下文:
<div id=\"toolbar\"></div>
<script type=\"text/javascript\">
Ext.create(\'Ext.toolbar.Toolbar\', {
renderTo: \'toolbar\',
name: \'searchBar\',
focusEl: \'toolbar\',
listeners: {
focusenter: function () {
console.log(\'focusenter\')
},
focus: function () {
console.log(\'focus\')
}
},
items: [
{
xtype: \'tbtext\',
html: \'Search\',
listeners: {
focusenter: function () {
console.log(\'focusenter\')
}
}
},
\'Case Sensitive\'
]
})
</script>
以下是解决我的问题的纯 JavaScript。
document.getElementById(\'toolbar\').onclick = function () {
console.log(\'hello world\');
}
我究竟做错了什么?
标签: extjs