javascript - formatSelection not working in select2.js -


i using select2.js populate field multiple values using ajax call.

below code using.

html

<input id="id_test_name" class="form-control"> 

script

<script type="text/javascript">     $("#id_test_name").select2({         placeholder: "search item",         minimuminputlength: 2,         ajax: {             url: "/resourse/?format=json&name=xyz",             datatype: 'json',             quietmillis: 100,             data: function (term, page) {                 return {                     option: term                 };             },             results: function (data, page) {                 return {                     results: $.map(data.results, function (item) {                         return {                             name: item.name,                             abbreviation: item.abbreviation,                             id: item.id                         }                     })                 };             }         },         formatresult: function (data, term) {             return data.name + '(' +  data.abbreviation +')';         },         formatselection: function (data) {             return data.name + '(' +  data.abbreviation +')';         },         dropdowncssclass: "bigdrop",         escapemarkup: function (m) {             return m;         }     }); </script> 

results populating in dropdown not able select populated results, not able find doing wrong?

also need id of selected results in other(hidden) field.

update: jsfiddle: http://jsfiddle.net/n5phohov/2


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -