开发者

jsTree causes that links on whole page are broken

开发者 https://www.devze.com 2022-12-28 03:30 出处:网络
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:

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开发者_StackOverflow社区(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!


<script type="text/javascript">
    $(function() { <--- here change to --> $(document).ready(function(){
        $("#industries").tree({

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消