Warn user of unsaved changes when swapping to a different view

6 posts, 0 answers
  1. Richard
    Richard avatar
    13 posts
    Member since:
    May 2013

    Posted 27 Sep 2013 Link to this post

    Hi All,

    Now I admit the answer may be simple, but I can't find a solution yet.

    Anyway I have a SPA with MVVM bindings.  How do I warn a user that they forgot to press the save button when they switch views, either via router.navigate or bookmarks.

    I have looked at the router change event, but I can't cancel the route.  

    I have looked at various demos and documentation.

    Regards

    Richard...
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 01 Oct 2013 Link to this post

    Hi Richard,

    I would suggest you to try to prevent the default of the change event of the router. Something like this:

    router.bind("change", function(e) {
       e.preventDefault();
    });

    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Richard
    Richard avatar
    13 posts
    Member since:
    May 2013

    Posted 01 Oct 2013 Link to this post

    Hi Kiril,

    I assumed that was the area to look at.  I have another question along these lines, how do I get hold of current view inside the router change event to check if there are changes?  Do I have to put the views collection on the global stack or is there a property on the event parameter I can use?

    I have looked at the properties but cannot find anything.  Maybe an idea to put a current view/next view properties on this event handle or have the view to allow change or not.

    Regards

    Richard...
  4. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 03 Oct 2013 Link to this post

    Hi Richard,

    Unfortunately there is not way to get an instance of the current view using the router. Maybe you can get the current url via the event argument and then find the respective view?

    As this question falls outside of the current topic I would like to remind you that it is a good practice to open different support requests for the various topics, as it will be easier to keep track and assign the responsible people that will give you the best possible answers.

    Thank you in advance for your cooperation.
     
    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Richard
    Richard avatar
    13 posts
    Member since:
    May 2013

    Posted 03 Oct 2013 Link to this post

    Hi Kiril,

    I don't think it is off topic as my question is how to prevent swapping of views if there is unsaved data in the current view.

    What you are suggesting will not work if I don't know what the current view is as the URL is where we are going to not coming from.

    I will take a step back and a do rethink on this.  There must be a solution somewhere, was hoping inside Kendo, but clearly not. From a UX experience this is making views/router only good for demos and very, very simple UI's.

    Regards

    Richard...
  6. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 04 Oct 2013 Link to this post

    Hello Richard,

    If you think that this feature should be added to the Kendo UI suit, maybe you should take a look at our uservoice forums, where you can post this as a new suggestion, so it can be taken into consideration for a future release.
     
    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top