Im having terrible trouble with getting the ajax attached to the select2 to fire. The select2 box is rendering correctly, however there is no call made to the controller when searching .
I have taken this from a working example in another project...which makes it all the more confusing
here are the JavaScript and css files in the layout header
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.full.js"></script>
here is my input
<input type="hidden" id="companyname" name="companyname" style="width: 100%;" />
here is my ajax call
$(document).ready(function () {
$("#companyname").select2({
placeholder: "Type to find a Provider",
theme: "bootstrap",
allowClear: true,
minimumInputLength: 2,
ajax: {
cache: false,
dataType: "json",
typ8e: "GET",
url: "@Url.Action("/CompanyHouse/SearchCompany")",
data: function(params){
return { companyname: params.term };
},
processResults: function (data, page) {
return { results: data };
}
}
// formatResult: contractFormatResult,
//formatSelection: contractFormatSelection,
//escapeMarkup: function (m) { return m; }
});
});