无法从 IE 中的 jsTree 中删除元素
Can't remove element from jsTree in IE
我在 html
页面中有一个自定义的 jsTree。
当用户单击 jsTree 中的 .delete
图标时,我将用户重定向到同一页面,查询字符串为 "delete",然后我执行逻辑以从该列表中删除该用户(也许一些 ajax 这里会更加用户友好,但我实际上并没有对页面进行编码。
这在 Firefox 和 Chrome 上运行顺利,但在 IE 上我遇到了一些问题。奇怪的麻烦。
首先:如果 IE 的 Developer Tools 打开,则一切正常。如果不是,它就不起作用。 HTTP 检查显示 jsTree 没有从定义的 url
参数中获取 HTML,因此,服务器开始更新它,但 jsTree 没有获取更新后的 HTML。
有趣的是,如果开发者工具打开,请求被发送,一切正常。
这是 jsTree 部分的代码:
$('#jstree_demo').jstree({
"core": {
"animation": 0,
"check_callback": true,
"themes": { "stripes": true },
'data': {
'url': function (node)
{
var ret = '/Some/Ajax/Page/Request.ashx?action=' + initialType;
if (node.data != null && node.data.nextType != null)
ret = '/Some/Ajax/Page/Request.ashx?action=' + node.data.nextType;
if (node.id === '#') {
ret += '&UserID=<%=Session("UserID")%>';
}
return ret;
}
}
},
"plugins": [
"search","state", "types", "wholerow"
]
}).on('changed.jstree', function (e, data) {
// some event handler
});
});
删除代码非常简单:几个 update
语句。这确实有效。
这可能是缓存问题。由于 jsTree 中的 core.data
是一个标准的 jQuery AJAX 配置尝试添加这个:
'data': {
'cache' : false,
'url': function (node) ...
这将使 jQuery 向您的 GET 请求附加一个时间戳,这将破坏缓存,您将始终访问服务器。
我在 html
页面中有一个自定义的 jsTree。
当用户单击 jsTree 中的 .delete
图标时,我将用户重定向到同一页面,查询字符串为 "delete",然后我执行逻辑以从该列表中删除该用户(也许一些 ajax 这里会更加用户友好,但我实际上并没有对页面进行编码。
这在 Firefox 和 Chrome 上运行顺利,但在 IE 上我遇到了一些问题。奇怪的麻烦。
首先:如果 IE 的 Developer Tools 打开,则一切正常。如果不是,它就不起作用。 HTTP 检查显示 jsTree 没有从定义的 url
参数中获取 HTML,因此,服务器开始更新它,但 jsTree 没有获取更新后的 HTML。
有趣的是,如果开发者工具打开,请求被发送,一切正常。
这是 jsTree 部分的代码:
$('#jstree_demo').jstree({
"core": {
"animation": 0,
"check_callback": true,
"themes": { "stripes": true },
'data': {
'url': function (node)
{
var ret = '/Some/Ajax/Page/Request.ashx?action=' + initialType;
if (node.data != null && node.data.nextType != null)
ret = '/Some/Ajax/Page/Request.ashx?action=' + node.data.nextType;
if (node.id === '#') {
ret += '&UserID=<%=Session("UserID")%>';
}
return ret;
}
}
},
"plugins": [
"search","state", "types", "wholerow"
]
}).on('changed.jstree', function (e, data) {
// some event handler
});
});
删除代码非常简单:几个 update
语句。这确实有效。
这可能是缓存问题。由于 jsTree 中的 core.data
是一个标准的 jQuery AJAX 配置尝试添加这个:
'data': {
'cache' : false,
'url': function (node) ...
这将使 jQuery 向您的 GET 请求附加一个时间戳,这将破坏缓存,您将始终访问服务器。