Please, help.
html:
<select id="select-client" class="form-control" style="width: 350px;"></select>
js:
$("#select-client").select2({
ajax: {
url: _app.url + "finduser",
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term
};
},
processResults: function (data) {
return {
results: data
};
},
cache: true
},
escapeMarkup: function (markup) { return markup; },
minimumInputLength: 2,
templateResult: formatClientRepo,
templateSelection: formatClientRepoSelection,
placeholder: "Enter user name"
});
And as result I've received this: http://prntscr.com/76jxvi I found many variants, such as empty option in select, or write placeholder in select, but nothing.
https://jsfiddle.net/xqhp0z0x/1/
in this example if we delete || repo.text
from formatRepoSelection
it will not work. Because the repo.text
is placeholder.
P.S. select2 4.0 do not need to empty option
tag for placeholder
working