Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在RubyonRails中在一个页面上多次重用分区_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 在RubyonRails中在一个页面上多次重用分区

Ruby on rails 在RubyonRails中在一个页面上多次重用分区,ruby-on-rails,ruby,Ruby On Rails,Ruby,我有一个使用以下方法渲染选择框的分部: <%= collection_select 'type', 'id', @types, "id", "name", {:prompt => true}, {:onchange => remote_function( :loading => "Form.Element.disable('go_button')", :url => '

我有一个使用以下方法渲染选择框的分部:

<%= collection_select 'type', 'id', @types, "id", "name", 
  {:prompt => true}, 
  {:onchange => 
              remote_function(
              :loading => "Form.Element.disable('go_button')",
              :url => '/sfc/criteria/services', 
              :with => "'type_id=' + encodeURIComponent(value) + '&use_wizard=#{use_wizard}'"),
    :class => "hosp_select_buttons"
} %>
返回第二个选择框。有没有办法轻松找到第一个?我应该使用javascript还是通过重做我的部分代码来解决这个问题


注意:下拉列表确实以单独的形式呈现。

我找到了一种方法,在html_选项块中指定一个ID。我已经在传递一个值,以便在向导中使用,因此我可以将该值附加到ID上,以区分这两个下拉列表

:id => "type_id_wizard_#{use_wizard}"

是的,每个元素都需要一个唯一的ID,页面可能也无法通过HTML验证。此外,除非它们是两种不同的形式,否则您将与CGI参数名发生冲突

如果它们是两种不同的形式,您可能只需在发布时设置:id即可,如果它们是相同的形式,您也需要抽象参数名称:

集合_选择'type',“id_向导35;{use_向导}”

:id => "type_id_wizard_#{use_wizard}"