【发布时间】:2016-07-13 09:19:45
【问题描述】:
我想使用 jQuery 附加一些包含 DustJS 变量的 HTML。这是我在 jQuery 中尝试做的事情:
$(document).on('ready', function(){
$("tr").click(function(){
$(this).after('<tr class="row-details">\
<td></td>\
<td colspan="4">\
<table class="sortable draggable">\
<thead>\
<tr>\
<th class="col-itemName">Item Name</th>\
<th class="col-quantity">Quantity</th>\
<th class="col-rate">Rate</th>\
<th class="col-amount">Amount</th>\
</tr>\
</thead>\
<tbody>\
{#items}\
<tr>\
<td>{.item.itemName}</td>\
<td>{.quantity}</td>\
<td>{.rate}</td>\
<td>{@math key="{.quantity}" method="multiply" operand="{.rate}"/}</td>\
</tr>\
{/items}\
</tbody>\
</table>\
</td>\
</tr>');
});
});
这是我的输出:
我如何评估这些变量???
【问题讨论】:
-
@Gothdo 我无法理解该页面上的任何内容。你想解释什么?
-
您只是在使用 jQuery 添加 HTML。您的代码中没有任何内容表明您正在使用 Dust。 jQuery 应该如何知道如何处理 Dust 参数?在尝试在 DOM 中渲染 HTML 之前,您需要将 HTML 字符串传递给
dust.render以便打印变量。 -
@Simon 你能举个例子吗??
标签: javascript jquery html dust.js