javascript - Preselecting value in select2 -


texbox dynamically filled remote call using select2 , how set preselected value. here code

<input type="hidden" id="e6">  $("#e6").select2({     placeholder: "search movie",     minimuminputlength: 1,     ajax: {         url: url,         datatype: 'jsonp',         data: function (term, page) {             return {                 q: term, // search term                  page_limit: 10, };          },          results: function (data, page) {                  return {results: data};         }     } });     

i tried preselect value 1049

$('#e6').select2('val', '1049');

but doesn't set value on textbox.

any ideas?

in case wants know how solve this

$("#e6").select2('data', {id: '1049', text: 'mylabel'}); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -