2016-04-01 21 views
0

我想改變我簡單的窗體默認日期格式爲我正在建設的事件網站上的jQuery datepicker。我跟着瑞恩貝茨的視頻,但沒有喜悅。這裏是我的代碼 -jQuery datepicker沒有顯示在我的應用程序

的application.js

//= require jquery 
//= require jquery_ujs 
//= require jquery-ui/datepicker 
//= require turbolinks 
//= require_tree . 

Events.coffee

jQuery -> 

    $("#datepicker").datepicker(
     dateFormat: "DD-mm-yy" 


    ); 

表 -

<%= f.input :image, as: :file, label: 'Image' %> 
<%= f.input :title, label: 'Title' %> 
<%= f.input :location, label: 'Location' %> 
<%= f.text_field :date, label: 'Date' %> 
<%= f.input :time, label: 'Time' %> 
<%= f.input :description, label: 'Description' %> 
<%= f.input :organised_by, label: 'Organised by' %> 
<%= f.input :organiser_description, label: 'Organiser description' %> 
<%= f.input :url, label: "Link to Organiser site" %> 

我的活動控制器具有以下方法 -

def new 
     @event = current_user.events.build 

    end 

我不確定#current_user.events.build是否需要在jQuery函數中顯示。我顯然沒有正確識別元​​素。任何幫助,將不勝感激。

+0

你在哪裏定義表單中的datepicker id? – uzaif

+0

嗨,你還可以分享rendrered html嗎?這可能是一個前端問題 – Vincent

+0

下面的答案對它進行了排序。謝謝。 –

回答

0

您需要分配一個id表單字段日期選擇器出現。

<%= f.text_field :date, id: 'datepicker', label: 'Date' %> 
+0

明白了,謝謝。 –

+0

嗨,任何想法如何讓showAnim工作?我在這裏發佈了另一個問題,但沒有一個答案似乎有效。 –

相關問題