-
26 Aug 2012 10:43 AM #1
Answered: Preventing unintentional navigation away from MVC app
Answered: Preventing unintentional navigation away from MVC app
Hi there,
I am yet to add full history support to my MVC application and would like a quick solution to prevent accidental navigation away from the application - made all the more likely for Mac users thanks to touch pad gestures.
My initial thought was to capture beforeunload events and to return a message to the user. This works fine, except I have a logout routine that redirects the user away from the MVC. I don't want to change this behaviour, but my understanding is that the only influence you have over beforeunload is setting the message displayed to the user, as this is a browser event.
Apart from implementing Ext.History support, are there any other suggestions?
Many thanks,
Dave.
-
Best Answer Posted by scottmartin
You would have to research this a bit online. It sounds like you would have to interfere with the default browser behavior to get what you want.
Scott.
-
27 Aug 2012 12:29 PM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,190
- Vote Rating
- 195
- Answers
- 436
Have a look at: window.onbeforeunload
Scott.
-
28 Aug 2012 8:17 AM #3
Hi Scott,
Thanks for your response.
I should have been more specific, that is the event I was referring to. My understanding of window.onbeforeunload is that you can't influence its behaviour.
So, in my situation, if I use window.onbeforeunload that back button and browser refresh are trapped. However, any other action that causes navigation away from the app is also trapped (e.g. logout and session timeout). I.e. if the user clicks logout, they get the window.onbeforeunload popup (annoying) and if the session times out the logout process is also interrupted by the window.onbeforeunload popup (more than annoying).
Basically I would like a solution that only capture the back button action, but doesn't complain if the logout button is clicked or the session times out. Does that make sense?
Any other suggestions?
Cheers,
Dave.
-
28 Aug 2012 9:55 AM #4
Ext.util.History
Ext.util.History
Have you tried using Ext.util.History?
http://docs.sencha.com/ext-js/4-0/#/...t.util.History
I have the same issue in an app I'm building, but I'm just using the onbeforeunload. I will be implementing History soon though...Good Luck!Scope = Perspective (think like an object)
-
28 Aug 2012 10:44 AM #5Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,190
- Vote Rating
- 195
- Answers
- 436
You would have to research this a bit online. It sounds like you would have to interfere with the default browser behavior to get what you want.
Scott.
-
28 Aug 2012 2:00 PM #6
Ext.History it is :-)
Thanks,
Dave.
-
19 Nov 2012 6:59 AM #7
Hi There
Hi There
Even I am having the same problem, can you please tell me how you have solved this issue.


Reply With Quote