ReferenceError:rails3中未定义转换

时间:2014-04-15 12:59:28

标签: javascript jquery ruby-on-rails assets

我正在使用rails3。 它有不同的javascript库,如moment(对于datetime picker)和init(对于ckeditor)。

当我使用DateTime Picker时,如果我再次回到日历那么点击时间就显得非常好

  

ReferenceError:rails3中未定义转换

在浏览器中。

无法解决

检查我的Gemfile

group :assets do
gem 'sass-rails',   '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem "jquery-datatables-rails", "~> 1.12.2"
gem 'jquery-ui-rails','4.2.0'
gem "twitter-bootstrap-rails",'2.2.8'
gem 'fancybox-rails'
gem 'momentjs-rails', '~> 2.5.0'
gem 'bootstrap3-datetimepicker-rails', '~> 3.0.0'
gem 'uglifier', '>= 1.0.3'
end

我的application.js是

//= require jquery
//= require jquery.ui.all
//= require dataTables/jquery.dataTables
//= require jquery_ujs 
//= require twitter/bootstrap 
//= require ckeditor/init 
//= require fancybox 
//= require moment 
//= require bootstrap-datetimepicker

并在

中加载文件
 <script type="text/javascript" src="/assets/twitter/bootstrap.js?body=1">
 <script type="text/javascript" src="/assets/ckeditor/init.js?body=1">
 <script type="text/javascript" src="/assets/ckeditor/ckeditor.js?body=1">
 <script type="text/javascript" src="/assets/jquery.browser.js?body=1">
 <script type="text/javascript" src="/assets/jquery.fancybox.js?body=1">
 <script type="text/javascript" src="/assets/fancybox.js?body=1">
 <script type="text/javascript" src="/assets/moment.js?body=1">
 <script type="text/javascript" src="/assets/bootstrap-datetimepicker.js?body=1">

浏览器中的错误有时会指向“init.js”和“datetimepicker.js”

请节省我的时间。

1 个答案:

答案 0 :(得分:1)

您可以通过bootstrao 3.0版本使用bootstrap datepicker文件来解决您的问题。

参考: Plesae请参阅以下链接获取更新文件,

http://eonasdan.github.io/bootstrap-datetimepicker/                          

rel="stylesheet">
    <link rel="stylesheet" type="text/css" media="screen"
     href="http://tarruda.github.com/bootstrap-datetimepicker/assets/css/bootstrap-datetimepicker.min.css">
  </head>
  <body>

<div class="container">
    <div class="row">
        <div class='col-sm-6'>
            <div class="form-group">
                <div class='input-group date' id='datetimepicker1'>
                    <input type='text' class="form-control" />
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>

          <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

        <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.min.js" ></script>

        <script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js" ></script>

        <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.min.js" ></script>

          <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/3.0.0/js/bootstrap-datetimepicker.min.js" ></script>

          <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.4.0/lang/en-gb.js" ></script>

        <script type="text/javascript">
            $(function () {
                $('#datetimepicker1').datetimepicker();
            });
        </script>
    </div>
</div>

小提琴::

http://jsfiddle.net/Ev6Md/