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

Closed
henry74 opened this Issue May 22, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@henry74

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.

Thanks,
Henry

@finnsson

This comment has been minimized.

Show comment
Hide comment
@finnsson

finnsson May 22, 2013

Owner

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 http://pagerjs.com/demo/#!/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.

Owner

finnsson commented May 22, 2013

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 http://pagerjs.com/demo/#!/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

This comment has been minimized.

Show comment
Hide comment
@henry74

henry74 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.

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.

@DKhalil DKhalil closed this May 8, 2017

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