Hi everyone,
I designed the custom ResultsAdapter below to run it on the specified element only. However, this design stopped pagination from working. The first data set loads via AJAX, but when I scroll down with the mouse, new data doesn’t load. I can’t find a solution. Anyone have any ideas? Thanks.
$.fn.select2.amd.define("SelectableOptionsAdapter",
["select2/results"],
function (Results) {
function CustomResults($element, options, dataAdapter) {
Results.call(this, $element, options, dataAdapter);
}
// Inherit from the original Results prototype
CustomResults.prototype = Object.create(Results.prototype);
CustomResults.prototype.constructor = CustomResults;
CustomResults.prototype.append = function (data) {
if (!data || !data.results) {
return;
}
// I am performing my custom operations here. This area works without any issues.
// Preserve pagination support by appending new data
Results.prototype.append.call(this, data);
};
return CustomResults;
}
);
*** I want my custom ResultsAdapter to work only on elements defined as below.
resultsAdapter: $.fn.select2.amd.require("SelectableOptionsAdapter")