2016-04-01 36 views
0

私が作成しているイベントサイトで、単純なフォームのデフォルトの日付形式をjQueryのdatepickerに変更しようとしています。私はライアン・ベイツのビデオを見たことがありますが、喜びはありません。ここに私のコードです -私のアプリケーションにjQueryの日付ピッカーが表示されない

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

Events.coffee

Application.js

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 
0123を

#current_user.events.buildがjQuery関数で表示する必要があるかどうかはわかりません。私は明らかに要素を適切に識別していません。どんな助けもありがとう。

+0

ここで、フォームにdatepicker idを定義しますか? – uzaif

+0

こんにちは、レンダリングされたHTMLも共有できますか?それはフロントエンドの問題かもしれない – Vincent

+0

以下の回答は、それをソートしました。ありがとうございました。 –

答えて

0

あなたが表示されるまで日付ピッカーのためフォームフィールドのidを割り当てる必要があります。

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

それはあります、ありがとう。 –

+0

こんにちは、どのように私はshowAnimが動作するように任意のアイデアですか?私はここに別の質問を掲載しましたが、答えのどれもうまくいかないようです。 –