[v2] Back: prompt to go back without saving

Hi Vladimir, I’ve one question.

I need to handle back and promp to the user if he wants to go back without saving (happens that many users used to go back insted of save and I control if he type something )

I’ve an event to handle back outside pageInit

$$(document).on('click', '.back', function(e) { e.preventDefault(); return; });

but it’s seems that It execute after user press “.back” link,

Hi, did you try with page event?

$$(document).on('page:beforeout', '.page[data-name="some-page"]', function (e) {

Event will be triggered right before page is going to be transitioned out of view


Hi @pvtallulah, Yes but it’s not help me, because I need to control when they click .back , not while is doing the “back”.

I’m able to fix it, using a different class, instead of general .back, but I want to know why first it does the back event and after handle the .back onclick event if this is the one who fires it.

You can’t prevent default click handler. You need to add another class to this back link and add custom handler for this link, and inside of this handler you need to check required condition and call router.back() when required

1 Like

Thanks again. I did it like you said.

1 Like