How to add a confirm prompt for page change?
How to add a confirm prompt for page change?
York
Posts: 5Questions: 3Answers: 0
I added a confirm prompt for page change, by using the page.dt event (https://datatables.net/reference/event/page).
How can I cancel the page change when the confirm prompt returns false?
JS Fiddle: http://jsfiddle.net/ebRXw/80/
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
There is no option to cancel the paging (it isn't mentioned anywhere in the documentation because there is no option to do that). The
page
event is simply to inform you that the paging has changed after it has changed.You would need to create a custom paging plug-in if you wanted to be able to confirm the paging change.
Allan
Here is a trick to do so.
Use option
preDrawCallback
to cancel a draw.Use
page.dt
andlength.dt
to reset the page/length controller value.js fiddle: http://jsfiddle.net/ktbf8day/18/
A simplified version is here. http://jsfiddle.net/ktbf8day/19/.
This version responses to all draw event, but not limited to specific ones. Just
preDrawCallback
is needed.A confirm prompt is useful to prevent user from losing data in edit mode.