I have a bound list using knockoutjs / mvc3
<div data-bind="foreach: phones">
<input data-bind='value: number' />
</div>
to send this to my controller action which is
[HttpPost]
public ActionResult Index([Deserialize] WizardModel wizard, IStepViewModel step)
{
}
Previously I was able to bind to my List< T > using Jquery by specifying the name on the input which would be
<input name="Phones[0].Name"
Phones[1].Number etc..
But I’m now im using knockout I’m not clear how this should work. Anyone steer me in the right direction.
Ta
You can do this using the attr binding in a template or foreach like this assuming your phone numbers are in an observable array.
Im also assuming you are using the latest version of knockout so you can use the $index.
This will allow you to name the inputs so they work with MVC model binding.