Tag: 自动对焦

如何将HTML5自动焦点添加到rails表单?

我有一个文本字段 = text_field_tag(‘search_text_1’, params[:search_text], options = {:type => ‘search’} ) 产生 我想要添加HTML5自动对焦,如 = text_field_tag(‘search_text_1’, params[:search_text], options = {:type => ‘search’, :autofocus => true} ) 这会产生 哪个确实有效,但我怎么能得到autofocus的实际HTML输出,就像HTML规范所示,即 # Not sure where it goes or if that matters 运用 options = {:type => ‘search’, :autofocus } 给 …/_search.html.haml:2: syntax error, unexpected ‘}’, expecting => …:type => ‘search’, […]