나는 네 스티드 (nested_attributes)의 입력 상자가있는 레일스에서 편집 뷰를 가지고 있습니다.javascript의 nested_attributes에서 반환 한 ID
<div class="form-group">
<%= f.fields_for :item_prices, :class => "col-sm-2" do |ff|%>
<%= ff.hidden_field :store_id %>
<div class="col-sm-8 input_cc_size">
<label><%= ff.object.store.name %></label>
<%= ff.text_field :regular_price, :class => "form-control input_cc_size_nested", :value => (number_with_precision(ff.object.regular_price, :precision => 2)) %>
</div>
<% end %>
</div>
동적으로 자바 스크립트에서 첫 번째 상자에 값을 입력하면 나머지는이 값을 사용합니다. 이 참조를 찾았습니다. Jquery: Mirror one text input to another 저는 자바 스크립트에서 그런 작업을하려고합니다. 중첩 된 특성의 ID를 javascript로 반환하고이를 통해 반복 할 수 있습니까? 내가
$('#item_item_prices_attributes_0_store_id').bind('keypress blur', function() {
$('#item_item_prices_attributes_1_store_id').val($(this).val());
$('#item_item_prices_attributes_2_store_id').val($(this).val());
});
처럼 뭔가를 할 수 있지만 중첩 된 속성을 내가 그렇게하는 방법을 모른다 표준 식별자합니다.
미리 감사드립니다. 하지 이드 태그 이름
템플릿 만이 아닌 실제 HTML을 보여줍니다. –