Pages with different view models #134

Closed
norbiu opened this Issue Jul 18, 2013 · 3 comments

Comments

Projects
None yet
5 participants

norbiu commented Jul 18, 2013

I've been trying to properly implement pager.js and it worked thus far for one page and one view model.

Page1VM = new Page1VM()
pager.extendWithPage(Page1VM);
ko.applyBindings(Page1VM);
pager.start();

And it works great, but how can I load different view models for different pages? Let's say I have:

I tried searching the Pager.js demo page, but nothing I tried worked, like "bind" and "with". I also tried the soluton posted here: #98 which didn't seem to work either.

Any ideas? Thanks!

I recently starting looking into Pager and I'm trying to figure out the same. Supporting different view models on different pages is a core concept of MVVM and Knockout so I really hope there's a way.

Owner

finnsson commented Jul 25, 2013

Hi,

I would recommend withOnShow and lazy bind view models on demand. Take a peek at the example-folder or do somethibng like requireVM in the demo. That will allow a clean seperation of view models between pages.

I understand that a lot of developers are calling applyBinding multiple times but that is something that wont go nicely with pager since it needs 1 main view model to jack into (at the moment).

On Jul 18, 2013, at 9:53, norbiu notifications@github.com wrote:

I've been trying to properly implement pager.js and it worked thus far for one page and one view model.

Page1VM = new Page1VM()
pager.extendWithPage(Page1VM);
ko.applyBindings(Page1VM);
pager.start();

And it works great, but how can I load different view models for different pages? Let's say I have:

I tried searching the Pager.js demo page, but nothing I tried worked, like "bind" and "with". I also tried the soluton posted here: #98 which didn't seem to work either.

Any ideas? Thanks!


Reply to this email directly or view it on GitHub.

uri3000 commented Jun 12, 2014

#98 seems to be updated with a link to this page: http://pagerjs.com/demo/#!/model/bind_to_vm

@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