views:

267

answers:

1

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!

A: 
<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.

fmsf
I;ve edited my original question. I've added the code you suggessted but it also didn't help
niao
I've added alert("test"+$(NODE).attr("id")); for this jsTree. I;ve noticed that this alert is also executed when I click on links within the page
niao