This is working perfectly for me, but I'd like to add an alternative solution using the numberDisplayed
option available in Bootstrap Multiselect. Here’s a working solution using that parameter:
$('.multiselect').multiselect({
numberDisplayed: 4, // This will display up to 4 selected items
});
In this case, numberDisplayed: 4
ensures that no more than 4 selected options are shown in the input field. If you select more than 4 options, the input field will display the summary text (e.g., "5 selected").
The numberDisplayed
option simplifies the implementation if you only want to limit the number of selected options displayed
Thank you!