English 中文(简体)
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





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签