Using jstree flags in forms

Sorry for the slightly ambiguous name. My problem is very specific (and this, probably, I am only a beginner), I just did not know how to explain this in the title.

I am currently updating a web page. On this web page there are 3 lists with elements in them, for example, in the list of Devices there are different types of cars. Each element has a checkbox, the user checks those that he wants to use, and then clicks the button. He then receives a report based on his choice.

<input type="button" class="mapbutton"  onclick="company.view.reports.serialize(this);" 
                style="width:280px;font-size:1em" 
                value="<fmt:message key="owner.text.open_report" />" />

This is the button code.

serialize: function(what){
              var m = company.model.report;
              var strDev = 'devices=';
              var devicesCB = $(".devicesCB:checked");
              if (devicesCB.length > 0){
                  for (var i=0;i<devicesCB.length;i++) {
                     strDev += devicesCB[i].value + ',';
                  }
                  strDev = strDev.substring(0, strDev.length - 1);
              }

and this is part of the serialization function that runs when the user clicks a button. The part $(".devicesCB:checked")is jQuery and returns all checked class flags "devicesCB". This line is also the key to my question.

checkbox : {
        "real_checkboxes" : "true",
        "override_ui" : "true",
        "real_checkboxes_names" : function(n){
            console.log("As");
            return[("area"+n[0].id),n[0].id];
        }
    },

jstree, , . , ? var cb = $(".jstree-checkbox:checked"), , var areasCB = $("#tree");, , .

, , jQuery javascript .

+3
1

:

$("#my_tree").jstree("get_checked", null, false).each(function() {
    //do something
});
+5

All Articles