我正在使用JsTree 1.0,並且無法使用複選框插件預先檢查複選框。Jstree - 預檢覆選框
這裏是我的全碼:
$(".tree").bind("loaded.jstree", function (event, data) {
$('.tree li.checked').each(function() {
$(this).prop("checked", true);
})
}).jstree({
"core" : { "animation" : 0},
"json_data" : {
"ajax" : {
"url" : "/admin/posts/get_taxonomy_tree",
"data" : function (n) {
return { id : n.attr ? n.attr("id") : 0 };
}
},
"progressive_render" : true
},
"checkbox" : {
"real_checkboxes" : true,
"real_checkboxes_names" : function(n){
return [("term_taxonomy_id_" + (n[0].id || Math.ceil(Math.random() * 10000))), 1];
}
},
"themes" : {
"url" : "/assets/admin/js/jstree/themes/default/style.css",
"icons": false
},
"plugins" : [ "themes", "json_data", "checkbox" ]
}).delegate("a", "click", function (event, data) { event.preventDefault(); });
我已經添加了綁定事件loading.jstree
,但這是不正確的 - 不工作。
任何想法?謝謝!
編輯:
解決辦法是添加類jstree-checked
,默認將預勾選
所以你想要的所有複選框最初有類「檢查」的權利? – Evan
我可以應用這個類,它目前不在json中返回。 – dzm