Tom
Tom

Reputation: 4097

knockout show editable table

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?

Upvotes: 0

Views: 150

Answers (1)

ZahiC
ZahiC

Reputation: 14707

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

Upvotes: 1

Related Questions