I'm try to fill my multiple select2 using ajax, but i don't have return on field.
That's my HTML code:
<input type="hidden" id="instituicaoSel" tabindex="-1" class="select2-offscreen" value="">
Javascript:
$('#instituicaoSel').select2(
{
placeholder: "Escolha uma ou mais instituições",
minimumInputLength: 1,
width: '100%',
multiple: true,
ajax: {
url: basepath + "perfil/buscarInstituicoes",
dataType: 'json',
quietMillis: 100,
data: function (term, page) {
return {
q: term,
page_limit: 10,
page: page
};
},
results: function (data, page)
{
var more = (page * 10) < data.total;
return { results: data.results, more: more };
},
dropdownCssClass: "bigdrop"
}
});
And that is my result on ajax:
[{"result":[{"id":"1","text":"Ag\u00eancia Brasileira de Desenvolvimento Industrial"}],"total":1}]
The value that I put on placeholder don't is shown.
<select id="sel" placeholder="MyPlaceHolder">
<option></option>
<option>Option value</option>
</select>
you need add <option></option>
an example http://hromnik.com/web/select2/
and the solution : http://hromnik.wordpress.com/2012/10/18/select2-placeholder-does-not-work-solution/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.