私はフォームを使用しています。 f.selectがオプションunificaçãoを選択したときに彼に見せたい。f.selectパラメータをjqueryに送信し、動的フォーム要素を表示します
私は例を見て、新しいオプションを選択するとアラートアプリを選択しますが、選択した要素をどのように機能させるのか、どのように彼にfを表示するかはわかりません。 fields_for:統一。
<div class="form-row">
<label>
<span>Evento</span>
<%= f.select :event, ['Reencaminhar', 'Reclassificar', 'Rejeitar alteracão de diagnóstico', 'Rejeitar reencaminhamento', 'Solicitar esclarecimento', 'Cancelar solicitação', 'Rejeitar cancelamento', 'Responder', 'Unificação', 'Envio de cópia de ID', 'Reiterar', 'Registrar Solicitação', 'Reabrir solicitação', 'Complementar solicitação'], {}, :onChange => "fillForm.test(this)" %>
</label>
</div>
<%= f.fields_for :unifications do |unification_form| %>
<label>
<%= unification_form.link_to_remove "Remover cpf" %>
<%= unification_form.text_field :cpf %>
</label>
<% end %>
requests.coffee
@fillForm =
test: ->
alert('Hello world')
Eduardo、あなたの質問は明確ではありません。フォーム、HTMLをすべて提供してください。イベントを選択してすぐに結果をサーバーに送信したいのですが、どのように動作しますか? –
いいえ、オプションを選択したい場合、オプションがUnificaçãoと等しい場合、f.fields_for:統一が画面に表示されます。このコードは、f.selectを変更すると、画面内でhello worldのみを表示します。 –