简体   繁体   English

datepicker不适用于FF和chrome,但适用于IE

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

I am stuck in weird problem. 我陷入了奇怪的问题。
I have used datepicker like this: 我已经这样使用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>

locally datepicker is working fine, but after uploading this to heroku calendar is not opening. 在本地datepicker可以正常工作,但是将其上传到heroku日历后无法打开。 I tried the answer as in this link , after that it started working on IE 8. i am unable to figure out what the problem is. 我尝试了此链接中的答案,此后它开始在IE 8上运行。我无法弄清楚问题是什么。 please guide me to right direction. 请引导我朝正确的方向前进。 Thanks 谢谢

This code uses Modernizr to detect whether the 'date' input type is supported. 此代码使用Modernizr来检测是否支持“日期”输入类型。 If it isn't supported, then it fails back to JQueryUI datepicker. 如果不支持,则它将故障恢复到JQueryUI datepicker。

Note: You will need to download JQueryUI and possibly change the paths to the CSS and JS files in your own code. 注意:您将需要下载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/ http://jsfiddle.net/2AaFk/1/

well i discovered that i ahve to run 'rake assets:precompile' anyway. 好吧,我发现我仍然要运行“ rake asset:precompile”。 i pushed my public/assets to git and heroku. 我把我的public/assets推到了git和heroku上。 i launched firebug and found that the error is related to mixed secure layers. 我启动了Firebug,发现错误与混合安全层有关。 I changed my jquery and jquery-ui links to https previously it was http because heroku uses https . 我将jqueryjquery-ui链接更改为https以前是http因为heroku使用https this solved my issue with calendar. 这解决了我的日历问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM