0

これらは私の見解のフィールドです。パートコードのオートコンプリートにより、パートコードテーブルからパートコードのリストが表示されます。選択したパーツコードに応じて、パーツコードテーブルの説明で説明を動的に更新する必要があります。

<div class="field">
<%= f.label "partcode" %><br />
<%=f.autocomplete_field :partcode, "/goods_ins/1/autocomplete_partcode_partcode" %>
</div>    
<div class="field">
<%= f.label "description" %><br />
<%= f.text_field :description, :autocomplete => :off %>
</div>

これは私のルートにあります:

resources :goods_ins do
  get :autocomplete_partcode_partcode, :collection => {:view => :get} 
end  

そして私のコントローラー:

autocomplete  :partcode, :partcode, :extra_data => [:description]
4

1 に答える 1

0

次の方法を使用して、

最初に、以下のようにテキスト フィールドに id を指定します

<%= f.text_field :description,:autocomplete=>:off, :id_element=>'#part_desc'%>

上記の要素 ID を使用して update_elements プロパティを以下のように設定します。

<%=f.autocomplete_field :partcode, "/goods_ins/1/autocomplete_partcode_partcode",:update_elements=>{:id =>'#part_code', :description=>'#part_desc'} %>
于 2012-07-03T13:24:08.457 に答える