0
votes

In knockout i have a foreach data-binding to populate a table:

...
<tbody data-bind="foreach: people">
    <tr>
        <td>
            <span data-bind="text: $data.Name"></span>
        </td>
        <td>
            <span data-bind="text: $data.Description"></span>
        </td>
    </tr>
</tbody>
...

In the script section:

self.people= ko.observableArray();
$.getJSON('/api/apipeople', self.people);

With this code i'm able to see a table with the people name and description. Now i want make the table fields editable so i've changed the

<span data-bind="text: $data.Name">

to

<span data-bind="value: $data.Name">

Why i don't see anything with data-bind = value? The object self.people contains all the data so why with 'text' binding i'm able to see the values and with 'value' binding i don't see anything?

1

1 Answers

1
votes

The "value" attribute is not defined for "span" elements. It is defined for elements such as "input" or "textarea".

For editable table you can follow this example - link