troubleshooting Question

JSTREE Check failure

Avatar of Evan Cutler
Evan CutlerFlag for United States of America asked on
7 Comments1 Solution1480 ViewsLast Modified:
I'm trying to fire this line:
$("#DivTree").jstree("check_node", $(this).text());

The $(this).text() works (I checked in firebug)...
but the Tree does not check the node...

Here's the code to the entire page:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Scratchpad.aspx.cs" Inherits="Scratchpad_Scratchpad" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <%--CSS links--%>
    <link href="../Styles/ui-lightness/jquery-ui-1.8.14.custom.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/grid/flexigrid.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/textarea/jquery.cleditor.css" rel="stylesheet" type="text/css" />

    <%--Javascript links--%>
    <script src="../Scripts/jquery-1.6.2.min.js" type="text/javascript"></script>
    <script src="../Scripts/jstree/jquery.jstree.js" type="text/javascript"></script>
    <script src="../Scripts/ui/jquery-ui-1.8.14.custom.js" type="text/javascript"></script>
    <script src="../Scripts/Grid/flexigrid.js" type="text/javascript"></script>
    <script src="../Scripts/textarea/jquery.cleditor.js" type="text/javascript"></script>
    <script type='text/javascript' language='javascript'>

        $(document).ready(function () {

                "xml_data": {
                    "ajax": {
                        "url": "../data_services/Menu.ashx",
                        //"url": "FieldsOfStudyAdmin.aspx?callback=GetNodesJson",
                        "data": function (n) {
                            return { id: n.attr ? n.attr("id") : 0 };
                "checkbox": {
                    "two_state": true,
                    "override_ui": true
                "plugins": ["themes", "xml_data", "search", "dnd", "ui", "checkbox"]
            }).bind("check_node.jstree uncheck_node.jstree", function (e, data) {
                var checked_ids = new Array();
                $.jstree._focused().get_checked(-1, true).each(function () {
                    if ( { checked_ids.push(; }
                $("#Fields").val(checked_ids.join(", "));

                url: '../data_services/Ads.ashx',
                dataType: 'xml',
                method: 'GET',
                colModel: [
		            { display: 'Title', name: 'Title', width: 150, sortable: true, align: 'left', process: getID },
		            { display: 'Text', name: 'Text', width: 250, sortable: true, align: 'left', process: getID },
		            { display: 'Date', name: 'Date', width: 150, sortable: true, align: 'left', process: getID },
		            { display: 'Fields', name: 'Fields', width: 200, sortable: true, align: 'left', process: getID }
                searchitems: [
		            { display: 'Title', name: 'Title' },
		            { display: 'Text', name: 'Text', isdefault: true }
                sortname: "Title",
                sortorder: "asc",
                usepager: true,
                title: 'Countries',
                singleSelect: true,
                useRp: true,
                rp: 15,
                showTableToggleBtn: true,
                width: 750,
                height: 200
            $('#update').click(function () {
                var text = $('#Text').val();
                text = text.replace("\n", "");
                text = text.replace("\r", "");
            function getID(celDiv, id) {
                $(celDiv).click(function () {
                        type: "Post",
                        url: "../data_services/AdForm.asmx/GetAd",
                        dataType: "xml",
                        data: "PK=" + id,
                        success: function (xml) {
                            $(xml).find('formdata').each(function () {
                                var fieldlist = new Array();
                                $(this).find('fields').each(function () {
                                    $(this).find('field').each(function () {
                                        $("#DivTree").jstree("check_node", $(this).text());
                                $("#Fields").val(fieldlist.join(', '));

            $("#search").click(function () {
                $("#divTree").jstree("search", $("#fieldsearch").attr('value'));
<asp:Content ID="Content2" runat="server" contentplaceholderid="MainContent">
<table id="ads"></table>
<div id="output"></div>

<div id="form">
        PK:     <input id="pk" /><br />
        Title:  <input id="Title" value="insert Title Here" size="71" /><br />
        Fields: <input id="Fields" size="70"/><br />
        Text:   <textarea id="Text" rows="10" cols="80"></textarea>
            <input id="fieldsearch" type="text" /><div id="search"><a href="#">search for node</a></div><br />
            <div id="divTree"></div>
<a href="#" id="update" >Update Advertisement</a><a href="#" id="addnew">Add new Advertisement</a>

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros