Hi,
I have a datatable on page and I have search functionality for the datatable on the page.when i try to search string it filters datatable. And when I redirect to another page and again come back to the same page the search filter(datatable ) retains.
I have written down function on onbeforeunload event as below
var unloadCatcher = function() {
var dateObjAjax = new Date();
var timestamp = dateObjAjax.getTime();
var sortColumnIndex = $('#example').dataTable().fnSettings().aaSorting[0][0];
var pageType = "EPPatientList";
var paginationSize = $("#example_length select option:selected").prop('value');
var sortDirection = $('#example').dataTable().fnSettings().aaSorting[0][1];
var searchText = "";
if ($('#search_input').is(':visible')) {
searchText = $('#search_input').val();
$("#hiddenSearchText").val(searchText);
}
else {
$("#hiddenSearchText").val("");
}
$.ajax({
url: "<%=userPreference%>&sortColumnIndex=" + sortColumnIndex
+ "&pageType=" + pageType
+ "&paginationSize=" + paginationSize
+ "&sortDirection=" + sortDirection
+ "&time="+timestamp,
type: "post",
data: $("#hiddenSearchForm").serialize(),
cache: false,
async: false,
success: function(data){
}
});
var otable = $('#example').DataTable();
var pageSize = otable.page.info().length;
var expdate = new Date();
expdate.setTime(expdate.getTime() + (60 * 60 * 1000 * 24 * 365 * 20));
$.cookie('SJM_PT_'+userLogonCookieName+'_PageSize',pageSize,{ expires: expdate });
}
window.onbeforeunload = unloadCatcher;
currently this function (window.onbeforeunload = unloadCatcher
doesn't work for me as I am using chrome 80.
And as per my knowledge Chrome version 80 does not support window.onbeforeunload events any more instead there are two new calls fetch and sendBeacon is supported in Chrome and other browsers except IE11. So is there any alternative?
Thanks in advance
I have a datatable on page and I have search functionality for the datatable on the page.when i try to search string it filters datatable. And when I redirect to another page and again come back to the same page the search filter(datatable ) retains.
I have written down function on onbeforeunload event as below
var unloadCatcher = function() {
var dateObjAjax = new Date();
var timestamp = dateObjAjax.getTime();
var sortColumnIndex = $('#example').dataTable().fnSettings().aaSorting[0][0];
var pageType = "EPPatientList";
var paginationSize = $("#example_length select option:selected").prop('value');
var sortDirection = $('#example').dataTable().fnSettings().aaSorting[0][1];
var searchText = "";
if ($('#search_input').is(':visible')) {
searchText = $('#search_input').val();
$("#hiddenSearchText").val(searchText);
}
else {
$("#hiddenSearchText").val("");
}
$.ajax({
url: "<%=userPreference%>&sortColumnIndex=" + sortColumnIndex
+ "&pageType=" + pageType
+ "&paginationSize=" + paginationSize
+ "&sortDirection=" + sortDirection
+ "&time="+timestamp,
type: "post",
data: $("#hiddenSearchForm").serialize(),
cache: false,
async: false,
success: function(data){
}
});
var otable = $('#example').DataTable();
var pageSize = otable.page.info().length;
var expdate = new Date();
expdate.setTime(expdate.getTime() + (60 * 60 * 1000 * 24 * 365 * 20));
$.cookie('SJM_PT_'+userLogonCookieName+'_PageSize',pageSize,{ expires: expdate });
}
window.onbeforeunload = unloadCatcher;
currently this function (window.onbeforeunload = unloadCatcher
And as per my knowledge Chrome version 80 does not support window.onbeforeunload events any more instead there are two new calls fetch and sendBeacon is supported in Chrome and other browsers except IE11. So is there any alternative?
Thanks in advance