Skip to content

QUESTION: Possible to have multiple view models without lazy loading? #118

henry74 opened this Issue May 22, 2013 · 2 comments

2 participants

henry74 commented May 22, 2013

When trying to use multiple view models it seemed like navigation stopped working. Is it possible to use multiple view models and if so, do you have to do anything special to get it to work?

I'd like to use it without lazy loading if possible - I'm not sure why you would lazy load view models...but that's another question.



I guess you want to run ko.applyBindings multiple times and I'm afraid it is not possible at the moment but I think it might be possible to fix (as long as you don't call ko.applyBindings on child elements of already bound elements). I'll investigate it.

Another alternative might be use use with: (see!/model/change_binding_context) but that would involve a main view model that holds all your normal view models. withOnShow can also load normal view models. They don't need to be lazy loaded (using requirejs or similar) - withOnShow will just make sure to lazy bind the view model to the view.

henry74 commented May 22, 2013

I was thinking is I could bind to children elements I could very simply use page ids for each model to keep them separate and clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.