【发布时间】:2015-01-20 19:08:37
【问题描述】:
我一直在测试一个包含一些 jQuery UI 元素的页面,而 Safari 让我有些头疼。查看链接:http://data-buckeye-590.appspot.com/index
第一个文本输入使用 jQuery 自动完成,两个日期字段都使用日期选择器。现在,日期选择器可以在 Chrome 上完美运行,但不能在 Safari 上运行。任何线索为什么会发生这种情况?
index.html
<!DOCTYPE html>
<html lang="pt_BR">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/jquery-ui/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons.css">
<link rel="stylesheet" href="styles/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="styles/main.css">
<link rel="import" href="elements/imports.html">
</head>
<body fullbleed layout vertical unresolved>
<h1>Datas de entrada e saída no hotel</h1>
<input type="text" id="form_date_in" autocomplete="off" readonly placeholder="Entrada">
<input type="text" id="form_date_out" autocomplete="off" readonly placeholder="Saída">
<script src="scripts/main.js"> </script>
</body>
</html>
main.js
document.addEventListener('polymer-ready', function() {
$("#form_date_in").datepicker({
numberOfMonths: 2,
dateFormat: 'dd-mm-yy',
minDate: "+1w",
maxDate: "+330d",
onClose: function(selectedDate) {
$("#form_date_out").datepicker("option", "minDate", selectedDate);
}
});
$("#form_date_out").datepicker({
numberOfMonths: 2,
dateFormat: 'dd-mm-yy',
maxDate: "+330d"
});
});
【问题讨论】:
-
您能否提供一个较小的示例,其中仅包含重现此错误所需的元素。您提供的大部分代码与您描述的问题无关。
-
你是对的。我已经清理了一些代码。
-
另一条信息。通过 Safari 的网络检查器,我注意到它抛出了一个错误,并且这些日期字段中的任何一个都被聚焦:
[Error] TypeError: null is not an object (evaluating 'b.ownerDocument.defaultView') (anonymous function) (jquery.min.js, line 3)
标签: jquery jquery-ui safari datepicker jquery-ui-datepicker