如何访问 jEditable DatePicker 选项(onSelect、minDate、maxDate)
我将 jEditable 与 jQuery DatePicker 一起使用。我正在尝试对日期范围进行验证。例如,如果在 startDate
字段中选择 2010 年 6 月 1 日,则用户无法在 endDate
字段中选择 2010 年 6 月 1 日之前的日期,反之亦然。
除验证部分外,所有其他代码均有效。据我所知,jEditable 版本中包含 jQuery-ui DatePicker 的完整版本,但我不知道如何使用它。
这是我正在使用的 DatePicker: https://github.com/qertoip/jeditable -datepicker/tree/master/src
DatePicker插件示例演示:http://thesingularity.pl/jeditable-datepicker-demo/
我的脚本
$( '#startDate' ).editable('AppUpdateServlet',{
indicator : '<img src="images/indicator.gif">',
type: 'datepicker',
datepicker: {
dateFormat: 'dd/mm/yy',
//minDate: '+1w' (this is working)
onSelect: function() {
//the alert is working
//alert("working");
//not working
$('#endDate').datepicker('option', {minDate: $(this).datepicker('getDate')});
}
}
});
$( '#endDate' ).editable('AppUpdateServlet',{
indicator : '<img src="images/indicator.gif">',
type: 'datepicker',
datepicker: {
dateFormat: 'dd/mm/yy',
onSelect: function() {
//not working
$('#startDate').datepicker('option', {minDate: $(this).datepicker('getDate')});
}
}
});
HTML 片段
<span id="startDate">
<%=test.getStartDate()%>
</span>
<span id="endDate">
<%=test.getEndDate()%>
</span>
I am using jEditable together with jQuery DatePicker. I am trying to do validation for a date range. For example, if 1st June 2010 is selected in the startDate
field, the user cannot select dates before 1st June 2010 in the endDate
field and vice versa.
All of the other codes are working except the validation part. What I understand is that the full version of jQuery-ui DatePicker is included in the jEditable version but I do not know how to use it.
This is the DatePicker I am using: https://github.com/qertoip/jeditable-datepicker/tree/master/src
Sample Demo of DatePicker plugin: http://thesingularity.pl/jeditable-datepicker-demo/
My script
$( '#startDate' ).editable('AppUpdateServlet',{
indicator : '<img src="images/indicator.gif">',
type: 'datepicker',
datepicker: {
dateFormat: 'dd/mm/yy',
//minDate: '+1w' (this is working)
onSelect: function() {
//the alert is working
//alert("working");
//not working
$('#endDate').datepicker('option', {minDate: $(this).datepicker('getDate')});
}
}
});
$( '#endDate' ).editable('AppUpdateServlet',{
indicator : '<img src="images/indicator.gif">',
type: 'datepicker',
datepicker: {
dateFormat: 'dd/mm/yy',
onSelect: function() {
//not working
$('#startDate').datepicker('option', {minDate: $(this).datepicker('getDate')});
}
}
});
HTML snippet
<span id="startDate">
<%=test.getStartDate()%>
</span>
<span id="endDate">
<%=test.getEndDate()%>
</span>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这对我有用:
This works for me:
无法在 jEditable 中引用日期选择器。我已改用纯 jQuery Datepicker 来解决我的问题。
Not possible to reference to datepicker in jEditable. I have switched to using pure jQuery Datepicker to solve my problem.