JayData and Knockout

JayData integrates well with knockout.  However, the sample codes I see all likes to bind a list of products to an observable array.  That observable array is then render as a html table with a Save button, with each table row containing a single product and an Edit button.  The user has to press the Edit button for that product, change the value (e.g. Title) and then press Save.

Here is one way to programmatically select a product to edit without requiring the user to press an Edit button. 

Assume you have already done the .toArray() to an observable array (e.g. obProducts), you should do the following:

  • loop through the observable array to find the observable product you want to edit.
  • It is important to note that you are not trying to filter the jaydata entity products.
  • assign the found observable product to the observable selectedItem.  Remember to use the subscribe() to attach and detach the observable.innerInstance to the jaydata entity products.

Ping me if you are interested in seeing a sample.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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