开发者

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

开发者 https://www.devze.com 2023-01-19 22:11 出处:网络
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

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

精彩评论

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

关注公众号