JQuery UI Multiselect how to get selected parameter values

lost my day while searching how to get selected parameter values ​​in Michael Aufreeter's jQuery UI widgets. Here is a link to his demo site and github: http://quasipartikel.at/multiselect/

As a result, I just need value fields for the selected parameters without sending a POST / GET to the PHP script. I tried many methods and to no avail. I need your help and ideas.

* Found a lot of topics about jquery ui multiselect, but useless due to Aufreiter: s *

+5
source share
5 answers

I went to the site you specified above and was able to run it on my Chrome console:

$('.ui-multiselect .selected li').each(function(idx,el){ console.log(el.title); });

, , , div.selected.

Edit:

Doh! , , . . . jQuery data(). , , "optionLink". option. ".selected" jQuery.data(), .

, , , "optionLink" jQuery , .

:

$('.ui-multiselect .selected li').each(function(idx,el){
    console.log(el);
    var link = $(el).data('optionLink');
    // link now points to a jQuery wrapped <option> tag


    // I do a test on link first.  not sure why, but one of them was undefined.
    // however, I got all four values.  So I'm not sure what the first <li>
    // is.  I'm thinking it the header...
    if(link){

        // here your value. add it to an array, or whatever you need to do.
        console.log(link.val());
    }

});

, . . , - . getSelectedOptions() .

+3

. Chrome

$("#countries").val();
+14

Try to access the selected values ​​in the close event.

eg.

$("#dropdown").multiselect({
    header: false,
    selectedList : 1,
    height: "auto",
}).multiselectfilter().bind("multiselectclose", function(event, ui) {
    var value = $("#dropdown").val();
});

Hope this helps.

+1
source

The best decision

$('#select').multiselect({
    selectAllValue: 'multiselect-all',
    enableCaseInsensitiveFiltering: true,
    enableFiltering: true,
    height: "auto",
    close: function() {
            debugger;
            var values = new Array();
            $(this).multiselect("getChecked").each(function(index, item) {

                values.push($(item).val());
            });
            $("input[id*=SelectedValues]").val(values.join(","));
    }
}); 
+1
source

You can try the following:

$('#ListBoxId').multiselect({
    isOpen: true,
    keepOpen: true,
    filter: true
});
0
source

All Articles