मुझे पता है कि समान खोज हैं, लेकिन मुझे वास्तव में मेरे मुद्दे पर एक उत्तर फिटिंग नहीं मिल रहा है।मैं उसी तालिका में दो बार डेटपिकर का उपयोग क्यों नहीं कर सकता?
मैं इस HTML
तालिका डायन गर्त एक सरणी पाशन है - मेरी ViewModel में परिभाषित:
<div class="formElement" id="AssimilationDT" style="overflow-x: auto; width: 100em;">
<table class="dataTable">
<thead>
<tr>
<th> 1 </th>
<th> 2 </th>
<th> 3</th>
<th> 4</th>
<th> 5</th>
<th> 6</th>
<th> 7</th>
<th> 8</th>
<th> 9</th>
<th> 10</th>
<th> 11</th>
<th> 12/th>
<th> 13</th>
<th> 14</th>
<th> 15</th>
<th> 16</th>
<th></th>
</tr>
</thead>
<tbody data-bind="foreach: assimilationRows">
<tr>
<td><input type="text" name="AssimilationDate" id="AssimilationDate" data-bind="event: { mouseover: assimilationDatePicker}, value: AssimilationDate"></td>
<td><input type="text" name="InvoiceSum" data-bind="value: InvoiceSum"></td>
<td><input type="text" name="FondAssimAmm" data-bind="value: FondAssimAmm"></td>
<td><input type="text" name="FondSgebFondPerc" data-bind="value: FondSgebFondPerc"></td>
<td><input type="text" name="FondWholeAssimPerc" data-bind="value: FondWholeAssimPerc"></td>
<td><input type="text" name="SgebAssimAmm" data-bind="value: SgebAssimAmm"></td>
<td><input type="text" name="SgebFondSgeb" data-bind="value: SgebFondSgeb"></td>
<td><input type="text" name="SgebWholeAssimPerc" data-bind="value: SgebWholeAssimPerc"></td>
<td><input type="text" name="FondSuppl" data-bind="value: FondSuppl"></td>
<td><input type="text" name="FondSupplNum" data-bind="value: FondSupplNum"></td>
<td><input type="text" name="FondSupplInvNum" data-bind="value: FondSupplInvNum"></td>
<td><input type="text" name="FondDesc" data-bind="value: FondDesc"></td>
<td><input type="text" name="SgebSuppl" data-bind="value: SgebSuppl"></td>
<td><input type="text" name="SgebSupplNum" data-bind="value: SgebSupplNum"></td>
<td><input type="text" name="SgebSupplInvNum" data-bind="value: SgebSupplInvNum"></td>
<td>
<img src="/HDSHubCreditMonitoring/js/images/close.jpg" alt="Close" data-bind="click: $root.removeAssimilationRow">
</td>
</tr>
</tbody>
</table>
<button type="button" id="newSupplierRow" class="button" data-bind="click: newAssimilationRow">Добави Ред</button>
</div>
क्या मैं अपने ViewModel में नीचे दिए गए कोड है - तालिका पंक्तियों से युक्त है और इसे निष्पादित करने के लिए माना जाता है .datepicker
:
AssimilationInfo = function(clientNum){
this.AssimilationDate = null;
this.InvoiceSum = null;
this.FondAssimAmm = null;
this.FondSgebFondPerc = null;
this.FondWholeAssimPerc = null;
this.SgebAssimAmm = null;
this.SgebFondSgeb = null;
this.SgebWholeAssimPerc = null;
this.FondSuppl = null;
this.FondSupplNum = null;
this.FondSupplInvNum = null;
this.FondDesc = null;
this.SgebSuppl = null;
this.SgebSupplNum = null;
this.SgebSupplInvNum = null;
this.SgebDesc = null;
assimilationDatePicker = (function() {
$("#AssimilationDate").datepicker({
yearRange: "-20:+100",
changeMonth: true,
changeYear: true,
dateFormat: "d-M-y"
});
});
},
और
newAssimilationRow = function(){
this.assimilationRows.push(new AssimilationInfo(this.clientNumber()));
},
removeAssimilationRow = function (ca){
assimilationRows.remove(ca);
},
उपरोक्त फ़ंक्शंस HTML तालिका में पंक्तियां जोड़ रहे हैं या हटा रहे हैं। मुझे जिस समस्या का सामना करना पड़ रहा है वह यह है कि .datepicker
केवल प्रथम तालिका पंक्ति पर काम कर रहा है - यदि मैं एक और पंक्ति जोड़ता हूं, तो यह अभी काम नहीं कर रहा है।
मुझे पूरा यकीन है कि मैं इसे सही तरीके से कॉल नहीं कर सकता, लेकिन मैं इस मुद्दे को शुरुआत के रूप में नहीं ढूंढ पा रहा हूं। क्या प्रत्येक टेबल पंक्ति पर datepicker
पर कॉल करने का कोई तरीका है?
अद्यतन
मैं
assimilationDatePicker = (function() {
$(".AssimilationDate").datepicker({
yearRange: "-20:+100",
changeMonth: true,
changeYear: true,
dateFormat: "d-M-y"
});
});
जोड़ा गया है और अब यह हर पंक्ति पर पता चलता है, लेकिन केवल 1 पंक्ति इनपुट का मान अद्यतन किया जाता है।
क्योंकि आप आईडी के लिए डेटपिकर बनाते हैं: '$ (" #AssimilationDate ") .datepicker', क्लास चयनकर्ता जोड़ने के लिए:' $ ("AssimilationDate ") .datepicker' और रूप में भी '
@krasu यह काम करता है, लेकिन, अब यह केवल अपडेट करता है पहले बॉक्स का मूल्य :( – Slim
'assimilationDatePicker = ...' - वैश्विक objcet है, इसे 'this.assimilationDatePicker = ...' का प्रयास करें, मेरे पास knockout.js के साथ विशेषज्ञता नहीं है, इसलिए सुनिश्चित न करें कि यह होगा मदद – krasu