1. #1
    Ext JS Premium Member
    Join Date
    Jan 2011
    Posts
    52
    Answers
    1
    Vote Rating
    0
    davidryan is on a distinguished road

      0  

    Default 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.

  2. 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.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,636
    Answers
    613
    Vote Rating
    400
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Have a look at: window.onbeforeunload

    Scott.

  4. #3
    Ext JS Premium Member
    Join Date
    Jan 2011
    Posts
    52
    Answers
    1
    Vote Rating
    0
    davidryan is on a distinguished road

      0  

    Default


    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.

  5. #4
    Sencha User
    Join Date
    Jul 2007
    Location
    Sterling, VA USA
    Posts
    46
    Vote Rating
    0
    ddanatzko is on a distinguished road

      0  

    Default 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)

  6. #5
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,636
    Answers
    613
    Vote Rating
    400
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    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.

  7. #6
    Ext JS Premium Member
    Join Date
    Jan 2011
    Posts
    52
    Answers
    1
    Vote Rating
    0
    davidryan is on a distinguished road

      0  

    Default


    Ext.History it is :-)

    Thanks,
    Dave.

  8. #7
    Sencha User
    Join Date
    Oct 2012
    Posts
    2
    Vote Rating
    0
    vinit8704 is on a distinguished road

      0  

    Default Hi There

    Hi There


    Even I am having the same problem, can you please tell me how you have solved this issue.

  9. #8
    Sencha User
    Join Date
    Feb 2010
    Location
    London, UK
    Posts
    15
    Vote Rating
    2
    titusaduxass is on a distinguished road

      0  

    Default


    Hi, I was having a similar issue with preventing the browser from returning to the previous page when the user hit the backspace button. After a lot of searching I found this link that uses the Ext.EventManager to identify whether or not the backspace button should perform the default function:
    http://www.learnsomethings.com/2012/...our-extjs-app/

    I have modified it slightly to allow for textareas and readOnly fields:
    Code:
    Ext.EventManager.addListener(Ext.getBody(), 'keydown', function(e) {
      if (e.getTarget().type != 'text' && e.getTarget().type != 'textarea') && e.getKey() == '8') {
        e.preventDefault();
      } else if ((e.getTarget().type == 'text' || e.getTarget().type == 'textarea') && e.getKey() == '8' && e.getTarget().readOnly) {
        e.preventDefault();
      }
    });
    The benefits of this is that if the browser 'back' button is clicked it still functions normally and navigating away from the page is unaffected.

    I hope this helps someone.

    Cj



film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar