I need a little help.
I have created a table that gets values from JSON response, but for this example lets create a hardcoded html table like following:
<table id=devtable>
<tr>
<th>ID</th>
<th>Name</th>
<th>Status</th>
</tr>
<tr>
<td>001</td>
<td>Jhon</td>
<td>Single</td>
</tr>
<tr>
<td>002</td>
<td>Mike</td>
<td>Married</td>
</tr>
<tr>
<td>003</td>
<td>Marrie</td>
<td>Complicated</td>
</tr>
</table>
ID : <input type=text name=ID data-bind=value: ID disabled/>
<br>
Name : <input type=text name=Name data-bind=value: Name disabled/>
<br>
Status : <input type=text name=Status data-bind=value: Status disabled/>
<br>
<input type=button value=Send disabled/>
Requirement is: when I select a row of table, values of columns goes to the input boxes and enable button as well. As I am trying to learn Knockout.js by doing this exercise. I think I have to make a viewmodel like this:
var rowModel = function (id, name, status) {
this.ID = ko.observable(id);
this.Name = ko.observable(name);
this.Status = ko.observable(status);
}
Link of project is here: http://jsfiddle.net/qWmat/