Rails DatePicker - Object [object Object]没有方法'datepicker' [英] Rails DatePicker - Object [object Object] has no method 'datepicker'

查看:191
本文介绍了Rails DatePicker - Object [object Object]没有方法'datepicker'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图添加datepicker到我的rails 3.2.8应用程序。

I'm trying to add datepicker to my rails 3.2.8 application.

由于它是rails 3+,我没有添加任何内容到application.html.erb。

Since it is rails 3+, I didn't add anything to the application.html.erb.

我的application.js是以下内容:

My application.js is the following:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .

$(function(){
    $("#transaction_deadline").datepicker();
});

在views / transactions / _form.html.erb中

And in views/transactions/_form.html.erb

我有:

<div class="field">
    <%= f.label :deadline %><br />
    <%= f.text_field :deadline %>
  </div>

但是仍然,datepicker不起作用,并提供:

But still, datepicker doesn't work and gives:


TypeError:Object [object Object]没有方法'datepicker'

TypeError: Object [object Object] has no method 'datepicker'

错误

如果您可以帮助我,这将是很棒的。

That would be great if you can help me.

谢谢,

推荐答案

根据这个 Railscast ,您应该在application.js和application.css中明确添加datepicker组件。

According to this Railscast , you should add the datepicker component explicitly both in your application.js and application.css .

在application.js中:

In application.js:

//= require jquery.ui.datepicker

和application.css:

and in application.css:

*= require jquery.ui.datepicker

这篇关于Rails DatePicker - Object [object Object]没有方法'datepicker'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆