javascript - jstree 节点上的 HTML 选择元素立即关闭
问题描述
select
jstree 节点上的元素在单击时立即关闭。input
类似地失去焦点,但可以用 JavaScript 解决。但是,它并不能解决select
. 下面是一个最小的可重现示例。我该如何解决?
$('#jstree').jstree({
core: {
data: [
{text:`Select <select><option>1</option><option>2</option></select>`},
{text:`Input <input type="text">`},
]
}
});
$(document).on("click", "input, select", (e) => {
// e.target.focus(); // fixes the problem only for input
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.12/themes/default/style.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.12/jstree.min.js"></script>
<div id="jstree"></div>
解决方案
推荐阅读
- google-apps-script - 社区连接器教程导致“未知数据源”
- class - 为什么不能在飞镖类中的方法体之外打印任何语句
- python-3.x - 如何使用 selenium python 从 Outlook 下载嵌入的 content-id 图像
- java - Spring 跟踪日志 null ModelAndView 返回
- sql - 想要通过在 Postgres 函数中一次性传递多个参数来获得输出
- winforms - 将事件通知从 Winforms 服务器应用程序发送到 Blazor 客户端应用程序的最佳方式是什么?
- docker - 操作:推送:未经授权访问存储库 docker Harbor 注册表
- excel - 在最小最大条件范围内分布数字
- javascript - 两个相同的命名标识符如何导致此代码中的无限循环?
- django - 我可以在 Django 的模板标签内有模板标签吗?