模态窗口中的 JQuery 日期选择器出现问题
我使用代码创建了一个模态表单/窗口:
$(function () {
var widthLen = window.screen.width - 10;
var heightLen = window.screen.height - 120;
$("#dialogOperation").dialog({
width: widthLen,
height: heightLen,
closeOnEscape: true,
modal: true,
close: function () {
window.location.href = "OperationMenu.aspx"
}
});
});
带有一个附加了日期选择器和其中按钮的文本框。一切工作正常,除了一个小问题 - 日期选择器日历总是在每次有回发时显示。每次控制事件后都会出现日历。
我想要发生的是仅当我单击文本框时才显示日历,这通常发生在非模式对话框的表单中。
当我尝试使用隐藏日期选择器时:
$(document).ready(function () {
$('#txtDate').datepicker('hide');
});
即使我在文本焦点上调用它,我也无法再显示日历:
$("#txtDate").focus(function () {
$('#txtDate').datepicker();
}).blur(function() {
$('#txtDate').datepicker('hide');
});
我也尝试将 z-index: 1003 放入 jquery css 中,但我仍然没有太多运气。
.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; z-index: 1003; }
任何可以帮助我解决这个问题的人将不胜感激。
提前致谢!!
问候, 哈兰德
I created a modal form/window using with the code:
$(function () {
var widthLen = window.screen.width - 10;
var heightLen = window.screen.height - 120;
$("#dialogOperation").dialog({
width: widthLen,
height: heightLen,
closeOnEscape: true,
modal: true,
close: function () {
window.location.href = "OperationMenu.aspx"
}
});
});
with a textbox that has date picker attached to it and buttons in it. Everything works fine except for a little issue - the date picker calendar is always displaying everytime there is a postback. After every control event the calendar is appears.
What I want to happen is to show the calendar only when I click the textbox which is commonly happening in the forms that are not modal dialog.
When I tried hiding the datepicker using:
$(document).ready(function () {
$('#txtDate').datepicker('hide');
});
I was only unable to show the calendar anymore even though I call it on a text focus:
$("#txtDate").focus(function () {
$('#txtDate').datepicker();
}).blur(function() {
$('#txtDate').datepicker('hide');
});
I have also tried putting z-index: 1003 inside the jquery css but I am still not having much luck.
.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; z-index: 1003; }
Anyone who can help me resolve this issue would be greatly appreciated.
Thanks in advance!!
Regards,
Harland
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用选项
showOn
http://docs.jquery.com/UI/Datepicker#option-showOn
或者先禁用日期选择器,然后使用对话框的
open
事件来启用它。对话框关闭时禁用。演示: http://jsfiddle.net/diode/Xawe2/
Either you can use the option
showOn
http://docs.jquery.com/UI/Datepicker#option-showOn
Or disable datepicker first and use the
open
event of dialog to enable it.Disable when dialog is closed.demo: http://jsfiddle.net/diode/Xawe2/
最后一行中的“show”怎么样?
what about 'show' in the last but one line?