Code:
<select id="filterUser" style="width:300px;">
<option value=""><option>
</select>
$("#filterUser").select2({
minimumInputLength: 2,
allowClear: true,
ajax: {
url: "/Home/SearchUser",
dataType: 'json',
data: function (params) {
return {
term: params.term
};
},
processResults: function (data) {
alert(data);
return {
results: data
};
},
results: function (data) {
return {
results: data
};
}
}
});
Json:
{
"results":[
{
"id":"987567",
"text":"Paredes, Mike"
},
{
"id":"432654",
"text":"Parker, Mike"
},
{
"id":"567987",
"text":"Parker, Mike"
},
{
"id":"345345",
"text":"Parisi, Mike"
},
{
"id":"454545",
"text":"Paredes Durval, Mike"
},
{
"id":"888888",
"text":"Parker, Mike"
},
{
"id":"666666",
"text":"Parker, Shondra"
},
{
"id":"555555",
"text":"Parzons, Jossie"
},
{
"id":"222222",
"text":"Paredes Jr, Mike"
},
{
"id":"111111",
"text":"Parra, Mike"
},
{
"id":"333333",
"text":"Paredes, Mike"
},
{
"id":"321321",
"text":"Park, Mike"
},
{
"id":"123123",
"text":"Parrish, Mike"
}
]
}
I'm using Select2 4.0.
--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at http://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.