我想改變我簡單的窗體默認日期格式爲我正在建設的事件網站上的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函數中顯示。我顯然沒有正確識別元素。任何幫助,將不勝感激。
你在哪裏定義表單中的datepicker id? – uzaif
嗨,你還可以分享rendrered html嗎?這可能是一個前端問題 – Vincent
下面的答案對它進行了排序。謝謝。 –