【问题标题】:jquery mobile datepicker doesnt workjquery mobile datepicker不起作用
【发布时间】:2015-12-19 15:45:03
【问题描述】:

您好,谁能告诉我为什么下面的 jquery mobile datepicker 不起作用,因为我直接从 http://jqueryui.com/datepicker/ 复制了以下是我的问题的屏幕截图。它只显示日期选择器的文本字段。最初我以为是浏览器问题,但它不适用于任何浏览器,还包括我目前使用的 phonegap 平台。Example of the problem

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
  </script>
</head>
<body>

<p>Date: <input type="text" id="datepicker"></p>


</body>
</html>

【问题讨论】:

    标签: javascript jquery cordova jquery-ui datepicker


    【解决方案1】:

    您的代码有效!我认为问题是另一个问题:

    来自http://demos.jquerymobile.com/1.4.1/datepicker/

    你有弹出日期选择器

    <input type="text" data-role="date">
    

    内联日期选择器

    <input type="text" data-role="date" data-inline="true">
    

    Popup 并不总是适合在小屏幕和移动设备上使用,因为包装器添加了一个内联选项此选项使日期选择器的日历在调用它的输入之后内联显示,从而避免与相关的问题弹出窗口。

    关于 Datepicker 小部件的文档:http://api.jqueryui.com/datepicker/

    关于 jQuery Mobile Wrapper 的信息和支持:https://github.com/arschmitz/jquery-mobile-datepicker-wrapper

    有关 datepicker inline 以及如何使用的更多信息,请查看以下问题:Combine inline jquery datepicker with an input field?,其中解释了如何使用:

    $(function(){
        $( "#datepicker" ).datepicker({
            inline: true
        })
    })
    

    【讨论】: