get checked values for jsTree - submit with form post

前端 未结 11 1643
南笙
南笙 2020-12-14 02:40

I\'m using the jsTree jQuery plugin with the checkbox theme. Does anyone know how to get the selected values with a form post?

Thank you!

11条回答
  •  囚心锁ツ
    2020-12-14 03:14

    The suggested solution from google groups however didn't work for partially checked nodes, in my case. I had to leave the get_checked out and do the following to get fully selected and partially selected nodes.

    $(".sector-tree").find(".jstree-undetermined").each(function(i,element){ checked_ids.push($(element).attr("id")); if ($(this).find(".jstree-undetermined").length == 0) { $(this).find(".jstree-checked").each(function(i, element){ checked_ids.push({$(element).attr("id")); }); } }); // collect the rest of the checked nodes that exist under checked parents $(".sector-tree").find(".jstree-checked").each(function(i, element){ //also includes the ones below 'undetermined' parent var selectedElement = $(element).attr("id"); if ( hasItem(selectedElement, checked_ids ) < 0 ) { checked_ids.push(selectedElement); } });

提交回复
热议问题