Closed bugged84 closed 5 years ago
I see this in the console log when arriving at my landing page.
router> map /chat-rooms to template id=ChatRoomList
router> map /chat-rooms(/:id) to template id=ChatRoom
router> routing /chat-rooms
router> route '' to template id=ChatRoomList
router> routed
I can make it work with the following.
window.location.replace("chat-rooms/" + chatRoomId);
This seems undesirable, though, when I have route templates configured.
The redirect
accepts a path. Try: dotnetify.react.router.redirect('chat-rooms/' + chatRoomId)
.
The other way is to use vm.$routeTo(<route object>)
where this.GetRoute(<template name>, <url pattern>)
.
@dsuryd I had tried passing that same path to dotnetify.react.router.redirect
but the function fails saying that length
cannot be read on an undefined
viewModels parameter.
Now that I thought about it, redirect is more of an internal method, not meant to be used directly. Can you try the vm.$routeTo instead.
On Fri, Nov 23, 2018 at 11:31 AM bugged84 notifications@github.com wrote:
[image: image] https://user-images.githubusercontent.com/23638686/48958352-fc43dd80-ef23-11e8-8b9b-4be3e20593fb.png
[image: image] https://user-images.githubusercontent.com/23638686/48958364-18477f00-ef24-11e8-87df-1baa562a680b.png
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dsuryd/dotNetify/issues/150#issuecomment-441307779, or mute the thread https://github.com/notifications/unsubscribe-auth/AOS8koaSmS83C1vtQ7iHGqmj40YiROlzks5uyE0lgaJpZM4Yw-ZC .
Not sure vm.$routeTo
will work for me then, since you said it requires a predefined route object on the view model. My route to a new chat room can't be predefined, as it can't be known until a user creates it at run-time.
You can create an initial Route object that you store in the component state. Then clone the object, modify its urlPattern property to point to the desired chat room Id , and pass it to vm.$routeTo.
On Fri, Nov 23, 2018 at 12:05 PM bugged84 notifications@github.com wrote:
Not sure vm.$routeTo will work for me then, since you said it requires a predefined route object on the view model. My route to a new chat room can't be predefined, as it can't be known until a user creates it at run-time.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dsuryd/dotNetify/issues/150#issuecomment-441311468, or mute the thread https://github.com/notifications/unsubscribe-auth/AOS8kndWXnRwuNZ3mHq_fw1YICxIImerks5uyFT3gaJpZM4Yw-ZC .
Closing this as the question has been answered.
@dsuryd I found your comments in this other issue, but they don't quite address my scenario. Do you have an example of redirecting to a template such as the one below?
Using a
<RouteLink>
component works fine to route to a chat room from a list of links, but what if I want to redirect the user to a specific chat room based on a message sent from aMultiCaseVM
?What should I replace the question marks with?