开发者

Using jquery within jquery Templates, is this possible?

I want to perform an if check with in jquery template:

jquery template

<script id="CardWallItem" type="text/x-jquery-tmpl">
    <div id="lc${ProductId}" class="card">
        <input class="ItemId" type="hidden" value="${CardId}"/>
        <a href="" class="oCloseButton" onclick="return $$.laneItems.deleteLane(this);">x</a>
        if($.parent().find('.ItemId').val() == ${EntityId}){
        <p class="text" onclick="return $$.laneItems.editCard(this);">${Desc}</p> 
        <div class="edit bg" style="display:none;">
            <input class="editval" type="text" maxlength="20" />
            <a class="button" href="" onclick="return $$.laneItems.saveTitle(this);">Save</a> 
        </div>
        }
    </div>
    <br /><br />
</script>

and as you can see the if check in between, this one:

if($.parent().find('.ItemId').val() == ${EntityId}){
            <p class="text" onclick="return $$.laneItems.editCard(this);">${Desc}</p> 
            <div class="edit bg" style="display:开发者_开发知识库none;">
                <input class="editval" type="text" maxlength="20" />
                <a class="button" href="" onclick="return $$.laneItems.saveTitle(this);">Save</a> 
            </div>
            }

as the output of this is that it is printing whole if statement on page. So can anyone please tell me what I should do?


The syntax of conditionals in jquery templates is different:

{{if CONDITION}}

{{else}}

{{/if}}

See the documentation of the if template tag.


JQuery template itself is any HTML markup, along with any of a set of template tags which enable some very rich scenarios for creating data-driven UI. The current set of tags that are supported in jQuery templates are:

- ${...}: Evaluate fields or expression
- {{each ...}}...{{/each}}: Iterate without creating template items
- {{if ...}}...{{else ...}}...{{/if}}: Conditional sections
- {{html ...}}: Insert markup from data
- {{tmpl ...}}: Composition, as template items
- {{wrap ...}}...{{/wrap}}: Composition, plus incorporation of wrapped HTML

And for more details and example please visit here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜