Rahul Murari
Rahul Murari

Reputation: 449

Select2 dropdown showing sometimes duplicate

I have added approx 10 fields in my view page of select2 dropdown using knockout Js but only few of them being duplicate which is multi select.

Html

<div class="multiselect" data-bind="css: { 'pink-selectbox' : Passengers() == null || Passengers() == '' }">
                            <select class="multipleAccom" data-bind="attr: { name:'['+$index()+'].Passengers' ,id: $index()+'_Passengers' },options: $root.PassengerList,selectedOptions:Passengers, optionsText: 'Text', optionsValue: 'Value',event: {change: $root.CheckPassengerAssignment.bind($data,$index())},valueAllowUnset : true" multiple="multiple"></select></div>

JS

 $('.multipleAccom').multiselect({
        includeSelectAllOption: true,
        numberDisplayed: 0,
    });

enter image description here

Upvotes: 3

Views: 1820

Answers (1)

Rahul Murari
Rahul Murari

Reputation: 449

It was knockout issue, my DOM is not updating the values that time and select2 pulgin called, after populating data in DOM select2 reinitialized so it's duplicating dropdown.

Upvotes: 1

Related Questions