How to Set Selected value in Multi-Value Select in Jquery-Select2.?

Well actually your only need $.each to get all values, it will help you jsfiddle.net/NdQbw/5 <div class=”divright”> <select id=”drp_Books_Ill_Illustrations” class=”leaderMultiSelctdropdown Books_Illustrations” name=”drp_Books_Ill_Illustrations” multiple=””> <option value=” “>No illustrations</option> <option value=”a” selected>Illustrations</option> <option value=”b”>Maps</option> <option value=”c” selected>selectedPortraits</option> </select> </div> <div class=”divright”> <select id=”drp_Books_Ill_Illustrations1″ class=” Books_Illustrations” name=”drp_Books_Ill_Illustrations” multiple=””> <option value=” “>No illustrations</option> <option value=”a”>Illustrations</option> <option value=”b”>Maps</option> <option value=”c”>selectedPortraits</option> … Read more

“query function not defined for Select2 undefined error”

Covered in this google group thread The problem was because of the extra div that was being added by the select2. Select2 had added new div with class “select2-container form-select” to wrap the select created. So the next time i loaded the function, the error was being thrown as select2 was being attached to the … Read more

How to use Select2 with JSON via Ajax request?

for select2 v4.0.0 slightly different $(“.itemSearch”).select2({ tags: true, multiple: true, tokenSeparators: [‘,’, ‘ ‘], minimumInputLength: 2, minimumResultsForSearch: 10, ajax: { url: URL, dataType: “json”, type: “GET”, data: function (params) { var queryParameters = { term: params.term } return queryParameters; }, processResults: function (data) { return { results: $.map(data, function (item) { return { text: item.tag_value, … Read more