How to stop .aspx from being reloaded when the table.ajax.reload is executed?
How to stop .aspx from being reloaded when the table.ajax.reload is executed?
I have a complex webform containing:
(1) A master page;
(2) A webform (.aspx);
(3) Multiple Bootstrap tabs; and,
(4) In one of the tabs, there is a DataTables list.
After use of a modal dialog to update data in the DataTables list (after the modal dialog is closed), I need to refresh the DataTables list but have the specific tab and DataTable be shown.
However, whenever I execute the $('#TableId').DataTable().ajax.reload(null, false) statement, the DataTable is reloaded but the focus goes back to the main .aspx page and it comes to the forefront. The DataTable is no longer visible (hidden behind the tabs).
I have used several different versions of the table.ajax.reload(null,false statement all with the same results -- the .aspx parent is always reloaded (in addition to the DataTables) and then the parent becomes the active window.
function RefreshListBtn_Click() {
//$('#table_id').DataTable({
// stateSave: true
//});
alert('I am at the reload script');
var table = $('#TableId').DataTable();
table.ajax.reload(null, false);
alert('The reload has executed -- we should be done now!!! Why is the .aspx reloading?');
// return false;
}
Please note the code above that is commented out has been included/excluded in serveral different combinations in an effort to stop this behavior.
Does anyone know of a way to stop the parent .aspx from reloading?
My thanks in advance!!
Answers
I suspect there is another event on your page that is causing the focus to go back to the main .aspx page. Have you tried commenting out all of the itereations of
table.ajax.reload(null, false);
so it doesn't exeute? Does it go back to the main page?Can you post a link to your page or a test case replicating the issue so we can help debug?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Never mind...I just solved my own issue. I was using a button on the usercontrol that contains the DataTable and forgot to include "return false;" in the OnClientClick event code.
My fault. It's working fine now.