簡體   English   中英

datepicker不適用於FF和chrome,但適用於IE

[英]datepicker not working on FF and chrome but it works on IE

我陷入了奇怪的問題。
我已經這樣使用datepicker

<h6>From:</h6>
<input type="text" name="from" data-behaviour='datepicker' data-date-format="yyyy-mm-dd">

<script type="text/javascript">
     $('[data-behaviour~=datepicker]').datepicker();
</script>

在本地datepicker可以正常工作,但是將其上傳到heroku日歷后無法打開。 我嘗試了此鏈接中的答案,此后它開始在IE 8上運行。我無法弄清楚問題是什么。 請引導我朝正確的方向前進。 謝謝

此代碼使用Modernizr來檢測是否支持“日期”輸入類型。 如果不支持,則它將故障恢復到JQueryUI datepicker。

注意:您將需要下載JQueryUI,並可能用自己的代碼更改CSS和JS文件的路徑。

    <!DOCTYPE html>
<html>
    <head>
        <title>Modernizer Detect 'date' input type</title>
        <link rel="stylesheet" type="text/css" href="jquery-ui-1.10.3/themes/base/jquery.ui.all.css"/>
        <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-1.7-development-only.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
        <script type="text/javascript" src="jquery-ui-1.10.3/ui/jquery.ui.core.js"></script>
        <script type="text/javascript" src="jquery-ui-1.10.3/ui/jquery.ui.widget.js"></script>
        <script type="text/javascript" src="jquery-ui-1.10.3/ui/jquery.ui.datepicker.js"></script>
<script type="text/javascript">
    $(function(){
        if(!Modernizr.inputtypes.date) {
            console.log("The 'date' input type is not supported, so using JQueryUI datepicker instead.");
            $("#theDate").datepicker();
        }
    });
</script>

<body>
        <form>
            <input id="theDate" type="date"/>
        </form>
    </body>
</html>
if ( $('input')[0].type != 'date' ) 
    $('input').datepicker();

http://jsfiddle.net/2AaFk/1/

好吧,我發現我仍然要運行“ rake asset:precompile”。 我把我的public/assets推到了git和heroku上。 我啟動了Firebug,發現錯誤與混合安全層有關。 我將jqueryjquery-ui鏈接更改為https以前是http因為heroku使用https 這解決了我的日歷問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM