开发者

Proper way to access a object property in a jquery-tmpl {{each}} statement

I'm using jquery-tmpl. My object model is simple -- SalesProspect, which contains a collection of SalesProspectAction objects. Both of those objects have a field named Status. How do I get the child's Status in the each loop? It always pulls the parent's.

<script id="tmplActions" type="text/x-jquery-tmpl">
    <p>${GuestName}</p>
    <table class="stdtable" cellpadding="3" cellspacing="0" width="100%">
        <thead><tr><td>Date</td><td>By</td><td>Changed To</td><td>Notes</td></tr></thead>
        <tbody>
            {{each(i,action) SalesProspectActions}}
            <tr>
                <td>${DateCreated}</td>
                <td>${CreatedBy}</td>
                <td>${Status}</td>
                <td>${Notes}</td>
            </tr>
        {{/each}}
      开发者_如何学编程  </tbody>
    </table>
</script>

I've tried a few different things, like {$action.Status}, etc., but no luck.


As noted in my comment (despite the typos...) the syntax is ${action.Status} NOT {$action.Status}.


are you sure that this code doesn't work?

{{each(i,action) SalesProspectActions}}
    <tr>
        <td>${action.Status}</td>
    </tr>
{{/each}}


object can be passed as template option. Here is what I did in my project:

http://codekiku.blogspot.in/2012/04/jquery-template-options-pass-objects-or.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜