2
我有一個嵌套的表格,並使用nested_form寶石在裏面我是用RATY明星在現場瑞安貝茨,形式給出Rails的問題與nested_form寶石和jQuery
<%= f.fields_for :round_questions do |question| %>
<%= question.label :question %>
<%= question.text_field :question %>
<div class="star-questions" > </div>
<%= question.text_field :answer %>
<% end %>
<%= f.link_to_add "Add a Question", :round_questions,
:class=> 'btn waves-effect waves-light btn-medium custom_btn_gray',:id => "add-fields" %>
和JavaScript給出作爲
$(document).ready(function() {
$('.star-questions').raty({
targetType : 'score',
targetKeep : true
});
$(document).on('click', '#add-fields', function(){
$('.star-questions').raty({
targetType : 'score',
targetKeep : true
});
});
的問題是,當我點擊添加問題上一星評級會空的,我知道爲什麼會這樣,因爲我再次路過RATY功能全明星-問題 請告訴我怎麼能我添加保留前一個明星的問題評級
是一個解決方案嗎?我沒有明白 – user4965201
@nishantvarshney你確定這是一個有效的JS? – hawk
@hawk我已編輯JS請通過它 – user4965201