This is the preferred way to implement a custom event in response to an AJAX request being completed on a data list or filter block.
The key is to first create a new, aliased version of the base AjaxComplete function. Then, you write a new function that overrides that one, but which calls the aliased version.
The example below is for a filter block. On a data list block, you'd just change the name of the function being overridden from "FilterBlock_AjaxComplete" to "DataList_AjaxComplete".
var baseFilterBlock_AjaxComplete = FilterBlock_AjaxComplete;
FilterBlock_AjaxComplete = function (blockID,resultsAsJSON) {
baseFilterBlock_AjaxComplete(blockID,resultsAsJSON);
// Do your custom thing here
}
Make sure that this code is scoped correctly -- that is, that it only runs on the specific pages where you need the custom event. For data lists, this is best done by including this code in the script file for the display template.
For Segmented Search - Added by Ann
var baseSegmentedSearch_AjaxComplete = SegmentedSearch_AjaxComplete;
SegmentedSearch_AjaxComplete = function (action,docID,blockID,position,resultsAsJSON) {
baseSegmentedSearch_AjaxComplete(action,docID,blockID,position,resultsAsJSON);
// Do your custom thing here
}
For Data list - Added by Ann
var baseDataList_AjaxComplete = DataList_AjaxComplete;
DataList_AjaxComplete = function (blockID, responseAsJSON, responseAsXml, responseAsText) {
baseDataList_AjaxComplete(blockID, responseAsJSON, responseAsXml, responseAsText);
// Do your custom thing here
}