私はいくつかのトラブルシューティングを行ってきましたが、プログラムでjstreeにノードを追加するという、かなり単純な操作だと思っていたことができませんでした。現在、私は想像できる最も簡単な方法でこれをやろうとしています:
$('#irrigationClimateStations')
.jstree({
'plugins' : ['themes', 'json_data', 'ui', 'crrm'],
'json_data': {
"data" : [
{
"data" : "A node",
"metadata" : { id : 23 },
"children" : [ "Child 1", "A Child 2" ]
}
]
},
'themes': {
'theme': 'weather'
}
});
ツリーは正常に作成されますが、別のノードを追加しようとしても何も起こりません (そして、jstree からエラーは表示されません)。
var newNode = {
'attr' : { 'id' : this.model.get('id') },
'data': {
'title': this.model.format('station_na'),
'icon': media_url + this.model._iconRootURL + 'weather-station-16x16.png'
}
};
// Add the tree element to the end of the tree
$.jstree._reference('#irrigationClimateStations').create_node("#irrigationClimateStations", "last", newNode);
ドキュメントまたはソース コードに基づいて API を解読できませんでした。また、コア ドキュメントで言及されている「方法 2」を使用してノードを作成しようとしました。
var parent = $('#irrigationClimateStations').jstree('get_selected');
$('#irrigationClimateStations').jstree("create", parent, "last", newNode, false, false);
何か助けはありますか?私はjstree v 1.0-rc3を実行しています