-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
withOnShow not updating on navigation #143
Comments
Did a quick jsFiddle to show the problem. |
Hi, I don't want to step on Oscar's toes, but I'm pretty sure that this happens because the page attempts to rebind the second time you view it as the source is not being loaded in, but you are changing the viewmodel with the withOnShow parameter. You could get around this by modifying the page to also use sourceOnShow or in my case I've added some code that copies the page contents into another field and then if this specific case is matched I replace the contents before it's bound again (not the best approach possibly, but it works). Cuinn. |
+1 on fixing this (I wish I understood @CuinnWylie 's description of what is going wrong). |
This broke at exactly
on knockoutjs. In pagerjs, I'm continuing to debug this. At the moment, pagerjs is virtually unusable for me, so let me know how I can be of more assistance. (@finnsson I hate to tag you, but you haven't responded to this issue yet and it has been 3 months, so I am just making sure you didn't miss it. Sorry to be annoying!!!) |
Instead of applying the bindings more than once, can we
? |
I think that will result in sourceOnShow implementations breaking. As a quick fix and until there is a better solution you can have a look at the code that I've implemented. At the top of p.init but after the declaration of m insert:
and then in the loadWithOnShow sub insert:
and move the with onShowLoaded to the bottom so that it looks like:
ps. I consider this to be a bit nasty and I'm looking into a better way to do it. Alternatively you could implement sourceOnShow for the page. I'll post back if I come up with a better solution or let me know if you come up with something good. |
Thanks @CuinnWylie. I took your solution. |
I'm using withOnShow to bind a viewmodel based on a wildcard id.
It works fine on the first page load (/view/1) but if I click on a link to /view/2 the viewModel is not updated, the first one is still used. But if i point my browser to /view/2 directly the correct viewModel loads.
Have I missed anything or can I force pagerjs to refresh to the new viewModel?
I have logged the viewModel returned by the showView function and it will return the correct vm on link navigation.
The text was updated successfully, but these errors were encountered: