2012-11-12 54 views
0

我想日期選擇器添加到我的滑軌3.2.8應用程序。的Rails的DatePicker - 對象的翻譯:有沒有方法「日期選擇器」

既然是軌道3+,我沒有給application.html.erb添加任何東西。

我的application.js如下:

// 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(); 
}); 

而且在觀點/數據/ _form.html.erb

我:

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

但儘管如此,日期選擇器沒有按」 t work and給出:

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

錯誤

這將是巨大的,如果你能幫助我。

感謝,

+0

你導入的jQuery UI庫?或至少日期選擇器小部件? –

+0

不是這些進口與 「<%= javascript_include_tag 」應用程序「 %>」 代碼? – CanCeylan

+0

我在問,你是否將jQuery UI/datepicker與jQuery庫一起導入? –

回答

0

根據這一Railscast,你都應該在你的application.js和application.css明確添加日期選擇器組件。

在application.js中:

//= require jquery.ui.datepicker 

和application.css:

*= require jquery.ui.datepicker 
相關問題