KnockoutJS - Multiple partial views within on main view?

Viewed 5114

I am trying to port an existing asp mvc app over to use knockoutjs (pure js/html) as I no longer really need any of the functionality within asp mvc. However one problem I can forsee is the way I am handling some of my pages.

I have one page which contains about 12 partial views, each partial has its own model. Now with Knockout JS it seems like you should only really have 1 viewmodel/view per page, however the page I have contains a large amount of information, the sections would be akin to:

  • Customer Details
  • Customer Address
  • Customer Recent Orders
  • Customer Cards
  • Customer Funds
  • ...

To make things more tricky if some details change in on part, it needs to change data in another part. So lets say you remove a card it then needs to tell the funds control that it no longer has a card so wont have funds. (This is all an abstract example, but hopefully illustrates the point)

So I am a bit unsure how to do this in knockout, as that would rather have it as one big model, which I would be happy with doing but it contains ALOT of information. As well as multiple forms, as you can update your address without having to update everything else.

So should I just make one large model for this view and just deal with it? or is there a way to have views talk to each other?

2 Answers
Related