Bootstrap Multiselect dropdown, with scroll populating
==================================================
function CustomerMultiSelect() {
$("#ddlCustomer").attr("multiple", "multiple");
$('#ddlCustomer').multiselect({
includeSelectAllOption: false,
enableFiltering: true,
enableCaseInsensitiveFiltering: true,
maxHeight: 200,
buttonWidth: '165px',
onChange: function (option, checked) {
var customer = $("#ddlCustomer").val();
console.log(bluebook);
}
});
$("#ddlCustomer").multiselect('clearSelection');
$('.multiselect-clear-filter').css('display', 'none');
$('.multiselect-search').css('width', '97%');
$('.customer ul')[0].addEventListener('scroll', dataLoadOnScroll, true);
}
fetch data on Ajax call and bind 100 records at once
=======================================
function GetCustomers(bluebook) {
$('#custLoad').show();
var blValues = bluebook.toString();
if (bluebook !== "null")
{
$.ajax({
url: "Default.aspx/GetCustomersOnBluebook",
type: "POST",
data: JSON.stringify({"values":blValues}),
contentType: 'application/json;charset=utf-8',
dataType: 'JSON',
success: function (data) {
$('#ddlCustomer').multiselect('destroy');
$('#ddlCustomer').empty();
var option = "";
if (data != null) {
alert(data.d.length);
currentRecordNumber = 300; page = 2;
datasource = data.d;
var newData = data.d.slice(0, 300);
for (i = 0; i < newData.length; i++) {
option += '<option value="' + newData[i].ID + '">' + newData[i].Name + '</option>';
}
$('#ddlCustomer').append(option);
}
CustomerMultiSelect();
$('#custLoad').hide();
},
failure: function (error) {
console.log(JSON.stringify(error));
}
});
}
}