[英]Rails readonly date_select
In my edit action, I don't want the date to be editable, but I still want the date to be visible. 在我的编辑操作中,我不希望日期可编辑,但我仍然希望日期可见。 Is it possible to make the
date_select
readonly while its value is still passed along with other params. 是否可以使
date_select
只读,而其值仍然与其他参数一起传递。 I have tried :disable => true
, but this way the date value is not passed along, and I need that value. 我试过
:disable => true
,但这样日期值不会传递,我需要该值。
<%= f.date_select :date %>
With JavaScript: 使用JavaScript:
In views: 在视图中:
<%= f.date_select :date, :disabled => true %>
In assets: 资产中:
$('form').submit(function () {
$('select').attr('disabled', false);
});
With CofeeScript: 使用CofeeScript:
In views: 在视图中:
<%= f.date_select :date, :disabled => true %>
In assets: 资产中:
$('form').submit ->
$('select').attr('disabled', false)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.