BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
855 stars 130 forks source link

{^{for myArray}}...{{else}}...{{/for}} {^{otherTag/}} starting with empty array does not bind correctly to inserts #326

Closed albanul closed 8 years ago

albanul commented 8 years ago

Hi, Boris!

I'm trying to render array values into the table. {{for}} tag renders only 1 row when I put self-made data-bounded tag after the {{for}} tag in the table.

Here is the sample: http://jsfiddle.net/y43cs47y/5/ Thanks!

BorisMoore commented 8 years ago

Yes, that is indeed a bug. Thanks for pointing it out! I'll work on a fix and post back here.

FWIW you can fix workaround the issue on your test page by writing:

    {^{if !arr || !arr.length}}
        <tr>
            <td> There are no results... </td>
        </tr>
    {{/if}}
    {^{for arr}}
        <tr>
            <td> {{:#getIndex()}} </td>
            <td> {{:#getIndex()}} </td>
            <td> {{:#getIndex()}} </td>
            <td> {{:#getIndex()}} </td>
            <td> {{:#getIndex()}} </td>
        </tr>
    {{/for}}
    {^{loadmore arr/}}
albanul commented 8 years ago

Thank you!

BorisMoore commented 8 years ago

Fixed in commit 71