2012-12-03 210 views
2

无论何时jsTree节点被点击(与jsTree节点关联的ID将被传递到该页面并且页面将相应地呈现),我想重定向到某个mypage.aspx页面。我在jsTree中有以下代码。jsTree节点点击事件

<script type="text/javascript"> 
    $(function() { 
     $("#mydiv").jstree({ 
      "plugins": ["themes", "json_data"], 
      "json_data": { 
       "ajax": { 
        "async": false, 
        // the URL to fetch the data 
        "url": "../Handlers/HandleRequest.aspx", 
        "data": function (n) { 
         return { 
          "PassID": "<% = UserNameCtrlID %>" 
         }; 
        } 
       } 
      }, 
      // Configuring the search plugin 
      "search": {}, 
      "types": {}, 
      "ui": { "initially_select": ["node_4"] }, 
      "core": { "initially_open": ["node_2", "node_3"] } 
     }); 
    }); 
    </script> 

在此先感谢!

+0

纠正!!!!!!!!!!!!!!!!! – Jai

+0

acutually没有答案为我工作...我怎么能接受! –

回答

3

老问题,但这是我做的工作。

  • 绑定JStree

    "plugins" : [ "types", "themes", "json_data" ,"ui"] 
    }).bind("select_node.jstree", function(event, data) { 
    
  • 使得Ajax调用来获取数据,并通过在下一页为隐藏变量所需的数据。

    $.ajax({ 
         type: "POST", 
         url: "getMyData.do", 
         data: inputParam, 
    contentType: "application/x-www-form-urlencoded;charset=UTF-8", 
        success: function(response) { 
        var url = '<%=request.getContextPath()%>/nextPage.do'; 
          // rediret to next page 
           window.location.replace(url); 
           } 
        }); 
    
  • 在MVC控制器 - 设置会话属性和读取,在重定向JSP。

  • 在JSP中将隐藏字段转换为JSON,并让它遍历。