I was looking at the Contacts editor sample on the knockout.js website:
http://knockoutjs.com/examples/contactsEditor.html
The sample works perfectly, but I need
The Json
method you are calling in your controller is meant to return a JsonResult
it does not create a JSON string. You would use this method to return json from an ajax call.
To return a JSON string to a view use something like this.
JavaScriptSerializer serializer = new JavaScriptSerializer();
ViewBag.InitialData = serializer.Serialize(people);
Then in your view code
To answer your second question. In order to pass global list data such as this simply define a new class ContactsList
e.g
public class ContactsList
{
public string Name { get;set; }
public string Owner { get;set; }
public IList People { get;set; }
}
Populate this and pass this to the JavascriptSerializer
instead. You will obviously need to adjust your js ContactsModel
accordingly.
EDIT
Here's a jsfiddle that demonstrates the changes needed.
http://jsfiddle.net/madcapnmckay/jRjwU/
Hope this helps.