在JQuery中访问rails循环变量

时间:2017-03-15 17:32:59

标签: javascript jquery ruby-on-rails ruby-on-rails-3

我有以下HTML代码:

.panel
.row
  .columns.small-6.medium-4
    = city_business_units_select_tag @appointment
  .columns.small-6.medium-4
    = select_tag 'appointment[asset_id]', options_for_select(current_cbu.assets.collect{|asset| [ asset.name, asset.id ] }, @appointment.asset_id), include_blank: true

.row
  .columns.small-6.medium-4
    =f.label :technician_id
    =f.select :technician_id, Technician.order(:last_name, :first_name).map {|t| [t.full_name, t.id]}, {selected: @technician_id, prompt: 'Select Technician', include_blank: true}

所以基本上当city_business_units_select_tag改变时,我想隐藏技术人员使用jquery选择的某些元素。当我遍历它时,如何为每个选项对象获取变量“技术人员”?

    $("#appointment_city_business_unit_id").change(function(){
       $("#appointment_technician_id > option").each(function () {
          console.log(technician.city_buiness_unit);
       });
    });

0 个答案:

没有答案