jQuery datepicker没有出现在Firefox中

时间:2013-10-14 15:36:51

标签: jquery-ui firefox twitter-bootstrap jquery-ui-datepicker

我有一个使用FLAT UI KIT的输入表单必须包含一个datepicker,所以我选择使用jQuery的widget。但是当我在Chrome中运行它时,日期选择器显示出来,而在Firefox上,它显示为一个简单的文本输入。 这是我的代码:

 <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My test &middot; stuff with datepicker</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Loading Bootstrap -->
    <link href="bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="bootstrap/css/prettify.css" rel="stylesheet">

    <!-- Loading Flat UI -->
    <link href="css/flat-ui.css" rel="stylesheet">
    <link href="css/docs.css" rel="stylesheet">

    <link rel="shortcut icon" href="images/favicon.ico">
    <!--  my addition jQuery UI for datepicker -->
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

    <script src="js/jquery-1.9.1.js"></script>
    <script src="js/jquery-ui-1.10.3.custom.min.js"></script>
    <script src="js/jquery.ui.touch-punch.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/bootstrap-select.js"></script>
    <script src="js/bootstrap-switch.js"></script>
    <script src="js/flatui-checkbox.js"></script>
    <script src="js/flatui-radio.js"></script>
    <script src="js/jquery.tagsinput.js"></script>
    <script src="js/jquery.placeholder.js"></script>
    <script src="bootstrap/js/google-code-prettify/prettify.js"></script>
    <script src="js/application.js"></script>                

    <style>
           .containerx {
        background-color: #1abc9c;
        background-repeat: no-repeat;
        background-position: bottom right;
        background-attachment: scroll;
        }      
        .titluedit{
        margin: 0 0 0 0;
        font-size:14px;
        }

        .titlueditx{
        margin: 0 0 0 0;
        font-size:14px;
        color:red;
        }

        fieldset { margin: 0 0 10px 0; }
    </style>

    <script>
    </script>

    <script>
            $(document).ready(function(){
                $(function() {
                    $( "#datepicker" ).datepicker();
                });    
            });    

    </script>    

  </head>
  <body>
  <img src="images/logo2.png" alt="logox" height="81" width="305"> 
        <h1 class="demo-panel-title" style="text-align:center; color:#d35400">XXXXXXXXX</h1>
        <h3 class="demo-panel-title" style="text-align:center; color:#1abc9c">New info</h3>

       <div class="container" style="width:900px; margin:0 auto;"> 
<form action="save.php" method="post">
            <div class="container" style="width:700px; margin:0 auto;"> 
                    <fieldset>
                    <p class="titlueditx">Name *:</p>
                    <input type="text" name="nume" value="" placeholder="Name" class="form-control" />
                    </fieldset>

                    <fieldset>
                        <p class="titlueditx">Medium time *:</p>
                        <input type="text" name="durata" value="" placeholder="minutes" class="form-control" />
                    </fieldset>

                        <p class="titlueditx">Start date  *:</p>
                        <input type="date" id="ui-datepicker" name="dataang" value="" class="form-control"/><br>

                    <fieldset>
                        <p class="titlueditx">Some other stuff *:</p>
                        <input type="text" name="sefutzul" value="" placeholder="Other relevant stuff" class="form-control" />
                    </fieldset>

            </div>

  <br><br>
    <div class="container" style="width:700px; margin:0 auto;"> 
        <table>
            <tr>
                <td>      
                    <input type="hidden" id="idhidfirma" name="idfirma" value="1" />       
                    <input type="hidden" id="idhnumefirma" name="numefirma" value="xxxxx" />       
                    <button type="submit" class="btn btn-hg btn-primary">        Save info      </button>  

</form>
                </td>
        <td>  
            <form action="mylist.php" method="post">                    
                <INPUT TYPE="hidden" NAME="idfirma" value="1">                     
                <INPUT TYPE="hidden" NAME="numefirma" value="xxxxx">             
                <button type="submit" class="btn btn-hg btn-danger">              Cancel            </button>  
            </form>
        </td>
    </tr>
           </table>
      </div>
    </div>      



</body></html>                

如何才能让它在Firefox TOO中运行?

同样在Chrome中,如何让日历在一天关闭?现在,日历一直显示,直到我点击屏幕上的其他位置。

3 个答案:

答案 0 :(得分:3)

问题不在于Firefox,而是在定义:

  1. 输入类型= ID为ui-datepicker的日期
  2. 将jQuery UI datepicker绑定到id datepicker
  3. 第二个选择器与任何元素都不匹配,因此jQuery UI datepicker没有绑定到任何东西;通过使用输入类型=日期Chrome自动呈现日历控件,因此您可以在Chrome中看到由于输入类型而导致的日历(请参阅。https://plus.google.com/+GoogleChromeDevelopers/posts/hTcMLVNKnec

    要解决所有浏览器中的问题,您可以在ui-datepicker元素中设置input type = text,并设置正确的选择器。

    代码:

     $(document).ready(function () {
         $("#ui-datepicker").datepicker();
     });
    

    演示:http://jsfiddle.net/IrvinDominin/zAKQe/

答案 1 :(得分:1)

日期选择器正在使用firefox,但datepicker的z-index位于“ - ”。所以它没有出现在firefix浏览器中。 显示通过jquery更新datepicker的z-index它将出现。

$(".datepicker").css("z-index","100");

答案 2 :(得分:1)

它将适用于mozila firefox如果不工作更新你的firefox版本。 我运行它有效。感谢

<head>
  <meta charset="UTF-8" />
  <title>Datepicker fadein</title>
  <link  href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://code.jquery.com/jquery-1.9.0.js"></script>
  <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
  <script type="text/javascript">
        $(function(){
            $('.datepicker').datepicker({showAnim: "fadeIn"});
        })
 </script>

在您的页面正文中使用输入

<input class="datepicker">