[英]Rails date_select and tabIndex
Attempting to set the tabIndex for date_select has proven to be difficult out of the box.尝试为 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"} %>
That is the best I've come up with, but that sets the tabIndex to be 11 for both of the select dropdowns.这是我想出的最好的方法,但是对于两个 select 下拉菜单,这会将 tabIndex 设置为 11。 How do I set the tabIndex of the month to 11 and the tabIndex of the year to 12?如何将月份的tabIndex设置为11,将年份的tabIndex设置为12?
You can't with the standard date_select
helper, all of the html options get passed to the DateTimeSelector
class, which creates drop downs for each field with these html options.您不能使用标准的date_select
帮助程序,所有 html 选项都会传递给DateTimeSelector
class,它使用这些 html 选项为每个字段创建下拉菜单。
You could modify this class to do what you need (see date_helper.rb in action pack if rails3) or you could write your own date_select that does this etc.您可以修改此 class 以执行您需要的操作(如果 rails3,请参阅操作包中的 date_helper.rb),或者您可以编写自己的 date_select 来执行此操作等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.