首页 > 解决方案 > JSTREE:列表未填充到 jquery 对话框中

问题描述

在成功的 ajax 调用中,我在 jquery 对话框中动态创建了一个 JSTREE,我正在获取要在控制台上显示的值。但树上什么也没有。我尝试了网站上的一些建议,但似乎没有显示列表。

success : function(data) {
      tmp7 += "<div style='width:600px;'>";
      tmp7 +="<br/>"; 
      tmp7 +="<div id='diagTree' style='width:200px; height:300px; float:left; background-color:white;'>";
      tmp7 +="<br/>";                                           
      tmp7 +="<div id='notetree' style='text-align: left'>";
      tmp7 +="</div>";                   
      tmp7 +="</div>";
      tmp7 +="<div style='width:400px; height:300px; float:left; background-color:white;'></div>";
      tmp7 += "</div>";
      var typelist = '<ul class="notetypelist">';
      $.each(data, function(key, val){
         typelist += "<li id='"+data[key].technicalid+"' name='nttype'"+counter+"' value='" + data[key].note_type + "'>" +techtype + "</li>";           
      });
      typelist += '</ul>';
      $("#notetree").jstree();
      //$('#notetree').html(typelist);
      $('#notetree').jstree(true).settings.core.data = typelist;
      $('#notetree').jstree(true).refresh();
      }

       var newDiv = $(document.createElement('div')); 
       $(newDiv).html(tmp7);
       $(newDiv).dialog({});

标签: jqueryjstree

解决方案


我通过在 html 页面上创建一个隐藏的潜水来解决这个问题,然后将其附加到对话框并启用它。使用此链接提示显示:jQuery Append/Add Hidden div to jQuery Dialog


推荐阅读