我正在实施一个称为定价的网格系统,其中我有一个名为定价的集合。我想要做的是在将它绑定到DOM之前更改定价集合模式。我想从中创建一个新对象
Pricing.find({})
所以我很容易在模板中操作它。它也应该像通常的集合一样被反应。
Pricing.js
Template.pricing.helpers({
pricing:Pricing.find({}),
publlisherIs: function (publisher) {
return this.publisher === publisher;
}
});
Pricing.html
<table class="table">
<thead>
<th class="col-md-1">Ask</th>
<th class="col-md-1">Bid</th>
<th class="col-md-1">Close</th>
</thead>
<tbody>
{{#each pricing}}
{{#if publlisherIs "GVM"}}
<tr data-id="{{ _id }}">
<!--<div class="col-md-2"> {{contract}}</div>-->
{{#each price}}
<td class=" price-input" data-price="{{type}}"><input id="item_to_add" size="8" value="{{value}}" type="text"></td>
{{/each}}
</tr>
{{/if}}
{{/each}}
</tbody>
</table>
现在我的定价单一文档架构就像这样
{
"_id" : "kSqH7QydFnPFHQmQH",
"timestamp" : ISODate("2015-10-11T11:49:50.241Z"),
"contractId" : "X5zTJ2y675PjmaLMx",
"contract" : "wwwer",
"price" : [{
"type" : "ask",
"value" : "4"
}, {
"type" : "bid",
"value" : 0
}, {
"type" : "close",
"value" : 0
}],
"publisher" : "GVM"
}