jquery chained을 사용하고 첫 번째 빈 옵션을 선택하면 두 번째 드롭 다운 목록이 회색으로 표시됩니다. 나는 그것을 잠글 수있는 두 번째 목록에 빈 옵션이 필요하다고 가정하지만 빈 옵션을 추가하는 방법을 모르겠습니다. 여기에 옵션을 선택레일에 공백 옵션 추가하기
<%= select_tag :equipment, options_for_select(Equipment.all.collect
{ |e| ["#{e.model} - #{e.serialNum}",e.id,
:class =>"#{e.handReceipt}"]},
html_options = {:id=>'equipment'}) %>
다운 목록의 첫 번째 드롭 당신이 손 영수증 유형을 선택하고 체인 jQuery로, 두 번째 목록은 적절한 손 영수증 속성 레코드를 표시 할 수 있습니다.
위의 선택에 공백 옵션을 어떻게 추가합니까? ,
<%= select_tag :equipment,
options_for_select( [["--",""],
Equipment.all.collect{ |e|
["#{e.model} - #{e.serialNum}",
e.id, :class =>"#{e.handReceipt}"]}],
html_options = {:id=>'equipment'}) %>
이 대신 테이블의 모든 레코드를 표시의
<select id="equipment" name="equipment">
<option value="">--</option>
<option value="["M4 - W432156", 10, {:class=>"Arms Room"}]">["PSN-13 - 176985", 1, {:class=>"Commo"}]</option>
</select>
목록 -
의 부적절한 디스플레이 결과 - 여기
편집 - 내가 지금까지 시도한 것입니다 공백 옵션과 두 번째 옵션 만 보여줍니다. 다음과 같은 오류에
<%= select_tag :equipment,
options_for_select( :include_blank => true,
Equipment.all.collect{ |e|
["#{e.model} - #{e.serialNum}",
e.id, :class =>"#{e.handReceipt}"]},
html_options = {:id=>'equipment'}) %>
결과 -
C:/Users/Sam/Documents/ruby/btrp/app/views/vehicles/edit.html.erb:19: syntax error, unexpected ',', expecting tASSOC
e.id, :class =>"#{e.handReceipt}"]},
'html_options'이 (가) 잘못되었습니다. 해시 형식을 사용해야하므로': html_options => {: id => '장비'} '가 올 Y 름 – daniloisr
표시되고 수정되었습니다. 이전에 제대로 설정 중이었고 오류가 발생하지 않았습니다. 캐치를 가져 주셔서 감사합니다. –