I am trying to load options for select2 from a list.
Here is what I have done so far:
View
----
<input type="hidden" id="myInput" multiple="multiple" />
Js file
-------
$("#myInput").select2({
placeholder: "select from the following",
ajax:
{
url:http:
dataType: "jsonp",
data: function (term, page) {
return {
q: term,
page_limit: 10,
apikey: "ju6z9mjyajq2djue3gbvv26t"
};
},
results: function (data, page) {
return { results: data}
}
}
});
myData.cs
---------
public jsonResult GetList(string q)
{
List<string> myList = new List<string>() {"one, "two", "three"};
return Json(myList);
}
I can see in debug it enters the "GetList" function but can't see any
results found in the select2 input.