leonidas / transparency

Transparency is a semantic template engine for the browser. It maps JSON objects to DOM elements by id, class and data-bind attributes.
http://leonidas.github.com/transparency/
MIT License
969 stars 112 forks source link

Binding doesn't work for root elements #128

Closed ravshansbox closed 9 years ago

pyykkis commented 9 years ago

hm..I'm not sure if understood the issue. Could you elaborate with a code example? Thanks!

ravshansbox commented 9 years ago
<table>
    <tbody data-bind="content">
        <tr>
            <td>
                <span data-bind="name"></span>
            </td>
        </tr>
    </tbody>
</table>
<script>
    $(function() {
        $('table').render({content: [{name: 'Row1'}, {name: 'Row2'}]}); // THIS WORKS!
        $('tbody').render({content: [{name: 'Row1'}, {name: 'Row2'}]}); // THIS DOESN'T WORK!
    });
</script>
ravshansbox commented 9 years ago

It would be nice if we could bind to tr instead of tbody, just like in angular.js :)

pyrou commented 9 years ago

This seems to be a non-issue.

If you want to perform the render directly on tbody level, you should pass the array as data

$('tbody').render([{name: 'Row1'}, {name: 'Row2'}]);