This is a migrated thread and some comments may be shown as answers.

Warn user of unsaved changes when swapping to a different view

5 Answers 259 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 27 Sep 2013, 08:47 AM
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...

5 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 01 Oct 2013, 06:50 AM
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!
0
Richard
Top achievements
Rank 1
answered on 01 Oct 2013, 08:40 AM
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...
0
Kiril Nikolov
Telerik team
answered on 03 Oct 2013, 07:01 AM
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!
0
Richard
Top achievements
Rank 1
answered on 03 Oct 2013, 08:24 AM
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...
0
Kiril Nikolov
Telerik team
answered on 04 Oct 2013, 02:59 PM
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!
Tags
MVVM
Asked by
Richard
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Richard
Top achievements
Rank 1
Share this question
or