Example 25: (Open the Dev Console and check the Log)

This example show you how to:

  • Load the plugin
  • Return the Selected ids and the Selected labels and the Unique labels when close the mSelect

HTML:
<select id="state_id" class="mSelect" multiple="multiple"></select>
JS:
$(function () {
    $('#state_id').mSelect({
        url: 'ajax/example11.php',
        columns: ['State Name', 'Country Name', 'Phone Code'],
        minWidth: 550,
        returnSelectedLabels: {  // Activate to return the selected labels
            enable: true 
            indexLabel: 2,       // return the "Country Name" Labels
            uniqueLabel: true    // return the unique labels as well
        },
        onDropdownHide: function(selectedIds, selectedLabels, uniqueSelectedLabels) { // callback functions
            console.log('the mSelect is closed');
            console.log('------- The selectedIds -------------');
            console.log(selectedIds);
            console.log('------- The selectedLabels ----------');
            console.log(selectedLabels); 
            console.log('------- The uniqueSelectedLabels ----');
            console.log(uniqueSelectedLabels);  
        }
    });
});