Hi, as explained in the documentation (Routes | Framework7 Documentation),
before the user leaves the page by clicking on the “back” button I would like to ask for confirmation through a dialog. If the user clicks on “Confirm”, the app must go back to the page, if he clicks on “Cancel” no.
This is my code. I can’t get the page back after pressing the “confirm” button.
Where am I doing wrong?
` routes: [
{
name: 'company-add',
path: 'add/',
url: './pages/company/add.html',
on: {
pageInit: function(e,page){
//some code
},
pageAfterIn: function(e,page){
//some code
}
},
beforeLeave: function ({ resolve, reject }) {
app.dialog.confirm(
'Are you sure you want to leave this page without saving data?','Confirm',
function () {
// go back
app.views.main.router.back();
},
function () {
// stay on page
}
)
}
}]}`
Thank you in advance, for your support.