get checked values for jsTree - submit with form post

前端 未结 11 1665
南笙
南笙 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:00

    In the last version (3.0), the API was changed.

    If you need just array of selected IDs (like in examples in this node), it is now very easy:

    var selectedElmsIds = $('#tree').jstree("get_selected");
    

    If you need to iterate over the selected elements, you just need to pass additional "true" parameter.

    var selectedElmsIds = [];
    var selectedElms = $('#tree').jstree("get_selected", true);
    $.each(selectedElms, function() {
        selectedElmsIds.push(this.id);
    });
    

提交回复
热议问题