繁体   English   中英

Rails date_select 和 tabIndex

[英]Rails date_select and tabIndex

尝试为 date_select 设置 tabIndex 已被证明很难开箱即用。

<%= f.date_select :card_expires_on, 
{:order => [:month, :year], :discard_day => true, :start_year => Date.today.year,
 :end_year => (Date.today.year+10), :add_month_numbers => true}, 
{:tabindex => "11"} %>

这是我想出的最好的方法,但是对于两个 select 下拉菜单,这会将 tabIndex 设置为 11。 如何将月份的tabIndex设置为11,将年份的tabIndex设置为12?

您不能使用标准的date_select帮助程序,所有 html 选项都会传递给DateTimeSelector class,它使用这些 html 选项为每个字段创建下拉菜单。

您可以修改此 class 以执行您需要的操作(如果 rails3,请参阅操作包中的 date_helper.rb),或者您可以编写自己的 date_select 来执行此操作等。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM