Q: What about conditional page refs? #136

Open
imrefazekas opened this Issue Jul 21, 2013 · 1 comment

Projects

None yet

1 participant

@imrefazekas

Hello,

I would like to navigate to a given page from multiple pages/paths and filling out the data on that page go back to the previous page.

So basically I would like to make conditional nagivation depending on page parameters or viewmodel parameters.

Is it possible to do so?
Unfortunately, the guard function's callback do not let me to pass path where to go only the window's location can be set which is not good enough.

So if I go from A to B, the back on B should put me back to A. In case of C is the source, the back on B should put me back to C.

Any idea would be great!

Thank you in advance!

@imrefazekas

The best way I have found so far is to extend the view model with routing-related observables like:

viewModel.originA = ko.observable( false );
viewModel.originC = ko.observable( false );

and define 2 back button:

#road_to_main(data-bind="if: originA")
a(data-bind="page-href: '../A'") Back

#road_to_personal(data-bind="if: originC")
a(data-bind="page-href: '../C'") Back

And in the afterShow function of A and C, I set those observable values.
However, I'm not too happy about this. An eye-disturbing work around.
I really hope to see a more elegant way for this conditional routing. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment