Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 224
ericvg Avatar asked Oct 14 '22 22:10

ericvg


1 Answers

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

like image 165
prodigitalson Avatar answered Oct 27 '22 02:10

prodigitalson