老实说,我希望您能帮助我,因为我花了相当长的时间在网上搜索合适的解决方案,但找不到任何解决方案。
我遇到的问题是我有一个 jQuery 日期选择器,我想在选择日期后保持打开状态,然后在单击其下方的“完成”按钮时将其关闭。我发现的最接近的东西来自堆栈溢出答案 https://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date从 2012 年开始,但不幸的是它隐藏了来自showButtonPanel: true
option.
这是我最近一次“尝试”的快照,但它再次不起作用:
$(function() {
$(".datepicker").datepicker({
showButtonPanel: true,
onSelect: function(){
$(this).val();
}
});
});
日历从以下位置触发:
<input class="datepicker" type="text" path="startDate" data-date-format="mm/dd/yyyy" />
仅供参考 - 我使用 jQuery 1.7.2.min.js (不幸的是,出于安全原因我无法更新)、jQuery-ui 1.10.3,当然还有 Bootstrap (版本 3.0.3,尽管我不确定这是否有帮助) 。
谢谢
这是一个工作小提琴:http://jsfiddle.net/9uc7dwoa/ http://jsfiddle.net/9uc7dwoa/
这是在 onSelect 中实现的技巧:
if (inst.inline)
this._updateDatepicker(inst);
else {
this._hideDatepicker(null, this._get(inst, 'duration'));
this._lastInput = inst.input[0];
if (typeof(inst.input[0]) != 'object')
inst.input[0].focus(); // restore focus
this._lastInput = null;
}
这里是答案的参考以及所使用的代码:jQuery Datepicker:单击日期时防止关闭选择器 https://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)