read = ->
$('#date_picker').datepicker
$(document).ready read
$(document).on "page:load", read
這是我使用上面的代碼是如何稱爲datepicker。我使用日期選擇器導軌寶石。以下是表格代碼自舉日期選擇器欄不工作
= simple_form_for :due_on,:url=> admin_requests_path,:method => "get",html: {id: "due_on_filter"} do |f|
= f.input :mydate,:disabled => 'disable', :input_html => { :data => {:behaviour => :datepicker },id: "date_picker"}
我無法使其工作。沒有錯誤,但日期選擇器不起作用。
這是我的application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require jquery.ui.core
//= require jquery_nested_form
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap3
//= require datatable_calls
//= require nprogress
//= require nprogress-turbolinks
//= require chosen-jquery
//= require chosen_calls
//= require filter_ajax_calls
//= require bootstrap-datepicker/core
//= require custom
HTML形式的原始輸出是:
<form accept-charset="UTF-8" action="/admin/requests" class="simple_form due_on" id="due_on_filter" method="get" novalidate="novalidate">
<div style="display:none"><input name="utf8" type="hidden" value="✓" /></div>
<div class="control-group string required due_on_mydate">
<label class="string required control-label" for="date_picker">
<abbr title="required">*</abbr> Mydate</label>
<div class="controls">
<input class="string required" data-behaviour="datepicker" id="date_picker" name="due_on[mydate]" type="text" />
</div>
</div>
</form>
正在輸出的html是什麼,是在表單上設置的ID爲date_picker?我不認爲你已經在表單上正確設置了你的ID,可能是錯誤的..雖然..worth檢查 – Richlewis
這是輸出html '
' – Aravind'有問題的錯字?? ()# $('#date_picker')。datepicker()' –