本帖最后由 福星 于 2025-5-23 16:59 编辑
首先在页面加载时用了js命令,文本框获取焦点时调用显示行命令,失去焦点时隐藏行。
现在的问题是 在图文列表做的点击命令无法生效,是不是被隐藏了所以无法生效?
代码分享给大家
(function() {
// 定义选择器常量
const INPUT_SELECTOR = "[fgcname='search'] .fgc-inputbox";
// 焦点处理函数
function handleFocus() {
Forguncy.CommandHelper.executeCellCommand("expand");
}
// 失焦处理函数
function handleBlur() {
Forguncy.CommandHelper.executeCellCommand("hide");
}
// 初始化
document.addEventListener('DOMContentLoaded', function() {
const input = document.querySelector(INPUT_SELECTOR);
if (input) {
// 绑定事件
input.addEventListener('focus', handleFocus);
input.addEventListener('blur', handleBlur);
// 自动聚焦(可选)
// input.focus();
}
});
//动态元素支持(可选)
document.body.addEventListener('focus', function(e) {
if (e.target.matches(INPUT_SELECTOR)) {
handleFocus(e);
}
}, true);
document.body.addEventListener('blur', function(e) {
if (e.target.matches(INPUT_SELECTOR)) {
handleBlur(e);
}
}, true);
})();
|