【发布时间】:2014-12-24 10:52:14
【问题描述】:
我正在使用 grails 2.1.1 和 jquery。我有一个表格,其中每行有三个字段,例如审核员、指定和审核日期。所以我声明了一个函数,它将克隆表的最后一行并将其添加为最后一行。现在它正在这样做,但问题是选择框和文本字段可以用于克隆,但日期选择器除外。它也克隆了日期选择器,但是当我单击它时,它不会显示要选择的日历,但在第一行会显示。我已经搜索了护目镜并尝试了很多东西但没有结果。谁能帮我解决这个问题?!!!下面是我的代码::
我的表格和操作按钮 >>>
<table id="auditors" class="auditors">
<tr><th>Auditor Name</th><th>Designation</th><th>Audit Date</th></tr>
<tr>
<td><g:select id="auditor0" name="auditor0" from="${audit.Auditor.list()}" optionKey="id" optionValue="AUDITOR_NAME" noSelection="['':'নির্বাচন করুন']" required="" value="${upManagementLetterInstance?.upRepresentative?.auditor?.id}" class="form-control"/></td>
<td><g:textField name="auditorDesignation0" id="auditorDesignation0" readonly="" class="form-control"/> </td>
<td><div class="bfh-datepicker" id="auditDate0" data-date="${formatDate(format:'MM/dd/yyyy',date:upManagementLetterInstance?.upRepresentative?.auditDate)}" data-close="true" data-name="auditDate0"></div></td>
</tr>
</table>
<input type="button" value="Add Another Auditor" onclick="addAnotherAuditor()"/>
我的功能>>>
<script>
var initialCounter = 0,addedCounter = 1;
function addAnotherAuditor(){
var row = $(".auditors > tbody > tr:last").clone();
row.find('select').each(function(){
this.id= this.name.replace(initialCounter, addedCounter);
this.name= this.name.replace(initialCounter, addedCounter);
})
$(".auditors > tbody > tr:last").after(rows);
initialCounter++;
addedCounter++;
}
</script>
【问题讨论】:
-
您能否提供有关您正在使用的引导日期选择器的信息?有很多,因此很难解释如何将它绑定到新添加的元素。
-
@JoshuaMoore 感谢您的回复,我正在使用 Bootstrap v3.2.0
-
你在使用这个日期选择器组件/库吗?:bootstrapformhelpers.com/datepicker
-
这里是 js 信息 >> eyecon.ro/bootstrap-datepicker & 这里是 css 信息 >> 版权所有 2012 Stefan Petre * 在 Apache License v2.0 下获得许可 * apache.org/licenses/LICENSE-2.0
标签: jquery twitter-bootstrap grails