jsTree 导致整个页面的链接损坏
问候, 我有以下问题。在我的 asp.net mvc 页面(这是一个部分视图)中,我创建了一个 jsTree 实例,如下所示:
<script type="text/javascript">
$(function() {
$("#industries").tree({
callback: {
onselect: function(NODE, TREE_OBJ) {
$("#SelectedIndustryROWGUID").val($(NODE).attr("id"));
$("#resultMessage").append($(NODE).attr("rel"));
}
},
data: {
type: "json",
async: true,
opts: {
method: "GET",
url: "/CreateMessage/GetIndustries/"
}
}
});
});
这工作正常,但是当我单击页面上的任何链接时,它不起作用。当我从上下文菜单中选择“在新选项卡中打开”选项时,将执行链接。当我删除上面的部分时,一切正常 有人可以帮我解决这个问题吗?
编辑 我将上面的代码更改如下:
<script type="text/javascript">
$(document).ready(function() {
$("#industries").tree({
callback: {
onselect: function(NODE, TREE_OBJ) {
$("#SelectedIndustryROWGUID").val($(NODE).attr("id"));
$("#resultMessage").append($(NODE).attr("rel"));
}
},
data: {
type: "json",
async: true,
opts: {
method: "POST",
url: "/CreateMessage/GetIndustries/"
}
}
});
});
(我添加了 $(document).ready(function() { ... 但它也没有帮助
EDIT2 我也在jsTree讨论组上提出了这个问题,并得到了答案。将jquery升级到1.4.2版本解决了问题!
Greetings,
I have the following problem. In my asp.net mvc page (which is a partial view) I create an instance of jsTree as follows:
<script type="text/javascript">
$(function() {
$("#industries").tree({
callback: {
onselect: function(NODE, TREE_OBJ) {
$("#SelectedIndustryROWGUID").val($(NODE).attr("id"));
$("#resultMessage").append($(NODE).attr("rel"));
}
},
data: {
type: "json",
async: true,
opts: {
method: "GET",
url: "/CreateMessage/GetIndustries/"
}
}
});
});
this works fine but then, when I click on any link on the page, it does not work. The links are executed when I choose "open in new tab" option from context menu. When I remove the above part, everything is working fine
Can someone please help me with this?
EDIT
I've changed the code above to be as follows:
<script type="text/javascript">
$(document).ready(function() {
$("#industries").tree({
callback: {
onselect: function(NODE, TREE_OBJ) {
$("#SelectedIndustryROWGUID").val($(NODE).attr("id"));
$("#resultMessage").append($(NODE).attr("rel"));
}
},
data: {
type: "json",
async: true,
opts: {
method: "POST",
url: "/CreateMessage/GetIndustries/"
}
}
});
});
(I've added $(document).ready(function() { ...
but it also didn't helped
EDIT2
I also asked this question on jsTree discussion group and I received an answer. Upgrading jquery to version 1.4.2 solved the problem!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当你执行$(something)时,jquery期望“something”是一个选择器,在你的代码中你直接给它一个函数,而不是任何jquery认为是选择器的东西。
when you do
$(something)
, jquery expects the "something" to be a selector, in your code your directly giving it a function instead of anything jquery considers to be a selector.