0
我试图有一些模态对话框显示包含窗体,而不会进入实际的意见。jquery-ui datepicker里面对话框不加载
一切工作正常,直到我想为其中一个字段添加datepicker。
在我的意见/计划/ _form我有:
<%= simple_form_for [@customer, @plan], :remote => true do |f| %>
<fieldset>
<%= f.input :price %>
<%= f.input :guests %>
<%= f.input :start_date, :as => :string, :input_html => { :class => 'date_picker' } %>
<%= f.input :end_date, :as => :string, :input_html => { :class => 'date_picker' } %>
<div class="form-actions">
<%= f.button :submit %>
</div>
</fieldset>
<% end %>
这是我从另一种观点称:
<%= link_to 'New Plan', new_customer_plan_path(session[:customer_id]), :class => 'btn btn-primary', :remote => true, :id => 'create_plan_link' %>
在我的application.js 我有:
$(document).ready(function() {
$('#create_plan_link').click(function(e) {
var url = $(this).attr('href');
$('#modal').dialog({
title: "New Plan",
draggable: true,
resizable: false,
modal: true,
width:'auto',
open: function(event, ui){
return $(this).load(url + ' #content');
$("input.date_picker").datepicker();}
});
});
});
现在,关于实际窗体,一切正常,但在选择字段时不显示日期选择器。
加载窗体时,我进入控制台,输入:
$("input.date_picker").datepicker();
然后它的作品!所以我错过了什么?
谢谢!像魅力一样工作 – Lievcin 2012-04-25 10:24:25
好的和快速的解决方案,谢谢! – scheien 2012-11-14 09:12:05