Interrupting a page/sort to query the user
Interrupting a page/sort to query the user
CodeWarrior
Posts: 2Questions: 0Answers: 0
Our tables are populated with checkboxed items.
When the user pages (or sorts) when any items are checked, we want to ask the user via a jQueryUI Dialog box if they want to navigate away (and lose their changes) or stay on the page.
Initially this seemed like it would be simple and re-usable (i.e. I could house the dialog code in such a way that a number of datatables instances could call it, but now I am unsure. Currently, I have the following specified in my dataTable options:
[code]
"fnPreDrawCallback" : function(table) {
if (CullAddress.AddressIsChecked()) {
var $warningDiv = $('div#pageWarning');
var warningText = "One or more Addresses are selected for Excluding or Tagging. Are you sure you wish to nvaigate away?";
$warningDiv.find("div#pageWarningText").html(warningText);
$warningDiv.dialog({
resizable: false,
height: "auto",
width: "auto",
modal: true,
buttons: {
"Leave Page": function () {
CullAddress.resetWarningText();
$warningDiv.dialog('close');
},
"Stay On Page": function () {
CullAddress.resetWarningText();
$warningDiv.dialog('close');
return false;
}
},
});
}
},
[/code]
I realize this is not the way javascript works. I have been too long in client coding. It is my understanding that what I am going to have to do is initially get arguments regarding the request (offset, pageSize, sSortDir, iSortCol, etc) popup the dialog, evaluate the user input, and re-call the page or sort operation if necessary. Is this correct? Seems like this should be easier than I am making it.
When the user pages (or sorts) when any items are checked, we want to ask the user via a jQueryUI Dialog box if they want to navigate away (and lose their changes) or stay on the page.
Initially this seemed like it would be simple and re-usable (i.e. I could house the dialog code in such a way that a number of datatables instances could call it, but now I am unsure. Currently, I have the following specified in my dataTable options:
[code]
"fnPreDrawCallback" : function(table) {
if (CullAddress.AddressIsChecked()) {
var $warningDiv = $('div#pageWarning');
var warningText = "One or more Addresses are selected for Excluding or Tagging. Are you sure you wish to nvaigate away?";
$warningDiv.find("div#pageWarningText").html(warningText);
$warningDiv.dialog({
resizable: false,
height: "auto",
width: "auto",
modal: true,
buttons: {
"Leave Page": function () {
CullAddress.resetWarningText();
$warningDiv.dialog('close');
},
"Stay On Page": function () {
CullAddress.resetWarningText();
$warningDiv.dialog('close');
return false;
}
},
});
}
},
[/code]
I realize this is not the way javascript works. I have been too long in client coding. It is my understanding that what I am going to have to do is initially get arguments regarding the request (offset, pageSize, sSortDir, iSortCol, etc) popup the dialog, evaluate the user input, and re-call the page or sort operation if necessary. Is this correct? Seems like this should be easier than I am making it.
This discussion has been closed.
Replies
http://stackoverflow.com/questions/15368975/datatables-confirm-user-wishes-to-page