1
スレッドのトンを読んで1つ後の問題を解決した後。 大きな問題を1つスタックすると、出力がありません。ブートストラップツリービューは動作しません - 渡されたオブジェクトはまだ出力されません
私はブートストラップツリービューを使用して説明したように:それはJavaScriptオブジェクトのネストされた配列を提供することが必要だ木のために必要な階層構造を定義するために
を。
例
var tree = [
{
text: "Parent 1",
nodes: [
{
text: "Child 1",
nodes: [
{
text: "Grandchild 1"
},
{
text: "Grandchild 2"
}
]
},
{
text: "Child 2"
}
]
},
{
text: "Parent 2"
},
{
text: "Parent 3"
},
{
text: "Parent 4"
},
{
text: "Parent 5"
}
];
マイカテゴリー配列出力:
Array
(
[0] => Array
(
[text] => Housing
[href] => http://localhost/projekte/application/housing/housing
[tags] => ['5']
[nodes] => Array
(
[0] => Array
(
[text] => House
[href] => http://localhost/projekte/application/house/house
[tags] => ['20']
)
[1] => Array
(
[text] => Shared Apartments - Rooms
[href] => http://localhost/projekte/application/shared-apartments-rooms/shared-apartments-rooms
[tags] => ['19']
)
[2] => Array
(
[text] => Apartment
[href] => http://localhost/projekte/application/apartment/apartment
[tags] => ['18']
)
)
)
[1] => Array
(
[text] => Jobs
[href] => http://localhost/projekte/application/jobs/jobs
[tags] => ['2']
[nodes] => Array
(
[0] => Array
(
[text] => Full Time
[href] => http://localhost/projekte/application/full-time/full-time
[tags] => ['7']
)
[1] => Array
(
[text] => Part Time
[href] => http://localhost/projekte/application/part-time/part-time
[tags] => ['8']
)
[2] => Array
(
[text] => Internship
[href] => http://localhost/projekte/application/internship/internship
[tags] => ['9']
)
[3] => Array
(
[text] => Au pair
[href] => http://localhost/projekte/application/au-pair/au-pair
[tags] => ['10']
)
)
)
[2] => Array
(
[text] => Languages
[href] => http://localhost/projekte/application/languages/languages
[tags] => ['3']
[nodes] => Array
(
[0] => Array
(
[text] => English
[href] => http://localhost/projekte/application/english/english
[tags] => ['11']
)
[1] => Array
(
[text] => Spanish
[href] => http://localhost/projekte/application/spanish/spanish
[tags] => ['12']
)
[2] => Array
(
[text] => Other Languages
[href] => http://localhost/projekte/application/other-languages/other-languages
[tags] => ['13']
)
)
)
[3] => Array
(
[text] => Friendship
[href] => http://localhost/projekte/application/friendship/friendship
[tags] => ['17']
)
[4] => Array
(
[text] => Market
[href] => http://localhost/projekte/application/market/market
[tags] => ['6']
[nodes] => Array
(
[0] => Array
(
[text] => TV
[href] => http://localhost/projekte/application/tv/tv
[tags] => ['21']
)
[1] => Array
(
[text] => Audio
[href] => http://localhost/projekte/application/audio/audio
[tags] => ['22']
)
[2] => Array
(
[text] => Furniture
[href] => http://localhost/projekte/application/furniture/furniture
[tags] => ['23']
)
[3] => Array
(
[text] => IT
[href] => http://localhost/projekte/application/it/it
[tags] => ['24']
)
[4] => Array
(
[text] => Other Market
[href] => http://localhost/projekte/application/other-market/other-market
[tags] => ['25']
)
)
)
[5] => Array
(
[text] => Others
[href] => http://localhost/projekte/application/others/others
[tags] => ['4']
[nodes] => Array
(
[0] => Array
(
[text] => Events
[href] => http://localhost/projekte/application/events/events
[tags] => ['14']
)
[1] => Array
(
[text] => Hobbies
[href] => http://localhost/projekte/application/hobbies/hobbies
[tags] => ['15']
)
[2] => Array
(
[text] => Services
[href] => http://localhost/projekte/application/services/services
[tags] => ['16']
)
)
)
)
これは、ツリーが表示されるはずのコードです:
<div class="treeview" id="treeview1">
<ul class="list-group">
</ul>
</div>
<script type='text/javascript'>
var js_data = <?php json_encode($tree,JSON_FORCE_OBJECT) ?>;
var js_obj_data = JSON.parse(js_data);
function getTree() {
return js_obj_data;
}
$('#treeview1').treeview({data: getTree()});
</script>
注:私は、私が見つけたすべてのスレッドを読んで私の問題に対する答えはありません。 おかげ