Knockout JS – Separate Model from View Model

Knockout JS follows a MVVM approach. In the simple examples the ViewModel seems to hold two kinds of things:

  1. attributes of the Model object
  2. functions operating on the Model – typically via GUI interaction

While this is fine for smaller apps, as apps get bigger there is a growing need to define the Model clearly and separately. After tinkering a bit and some help from Stackoverflow I settled on this scheme. It has worked well for our app.

Define the model separately


Define the ViewModel


Define the View


This entry was posted in Tech bits, Web development and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s