【问题标题】:Loading jsTree v3 using ajax when clicking +单击 + 时使用 ajax 加载 jsTree v3
【发布时间】:2014-08-21 11:40:45
【问题描述】:

我有 ajax 往返工作与下面的代码。单击该节点时,我想填充该节点的子节点。

                      "core" : {                                                       
                      'data' : {                              
                          'url' : function(node) {
                              return "source.php";                                
                          },
                          'dataType': 'JSON',
                          'data' : function (node) {
                              return {'parentkey' : node.id, 'isajax' : '1'};
                          },

我无法在我新添加的节点旁边显示一个加号 (+)。我看过这个帖子

http://www.miketyka.com/2012/10/lazy-loading-with-jstree-and-ajax/

但这似乎适用于旧的网格版本。我还读到我应该在我的 json 中为父节点设置“children:true”,但这只会让我的树崩溃。请帮忙

【问题讨论】:

    标签: jstree


    【解决方案1】:

    我仍然不确定是什么导致了网格崩溃,我的 JSON 一定有问题,但是当从服务器 php 代码返回时,它可以工作,即。一个+号显示在空的父节点旁边,当它被点击时,它会触发下一个ajax请求。

    $dataArray = array("id" => "id1", "parent" => "#", "text" => "Simple root node", "children" => true);
    echo json_encode($dataArray);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多