所以我一直在破解我的腦子搞清楚這一點。我有一個foreach,吐出模板,我想要第一個元素有一個特殊的屬性。到目前爲止我找到的解決方案還沒有成功。Knockoutjs模板foreach,特別第一項
這是在foreach:
<h3 class="question">Geografi</h3>
<p class="answer" data-bind="template: { name: 'geographyTmpl', foreach: geographyList, templateOptions: { selections: selectedGeographies } }"></p>
這是模板:
<script id="geographyTmpl" type="text/html">
<input class="geoCheckList" validate="required:true, minlength:2" name="geoCheckList[]" type="checkbox" data-bind='value: $data, attr: { id: "Geo"+$index()},checked: $root.selectedGeographies' />
<label data-bind="text: $data, attr: { 'for': 'Geo'+$index()}"></label>
,我想補充說: 「驗證=」 要求:真實,使用MINLENGTH:2"到第一個元素
我需要做什麼?
如果有幫助,它的jQuery驗證。
謝謝,這工作!我仍然在驗證方面遇到了一些麻煩,但至少我現在可以有一個特殊的第一項。 – 2013-03-11 14:14:29
好了,現在就修好了。再次感謝:) – 2013-03-11 14:26:28
你歡迎.... – 2013-03-11 14:34:13