【发布时间】:2015-11-03 16:49:40
【问题描述】:
我有这个输入的简单表单:
<%= f.input :seleced_seats, collection: @event.seats, label: "-", label_html: { style: 'visibility: hidden; height: 0px;'}, include_blank: false %>
它包含我想使用 AJAX 更新的选项。我获取输入数组(data.seats)的 JavaScript 是:
$("#event_seleced_seats").change(function(){
var seleced_seats = $(this).val();
var seleced_term = $("*[class='list-group-item active']").attr('id');
jQuery.getJSON(window.location.href + "/price", {edition: seleced_seats, term: seleced_term}, function(data) {
$("#price").text(data.total_price);
$("#termA").text(data.seats);
console.log(data.seats);
});
});
如何使用 data.seats 中的数据重绘 f.input?
【问题讨论】:
标签: javascript ruby-on-rails ajax ruby-on-rails-4 simple-form