1.增加修改单选题时页面js的刷新

2.修改单选题时删除某些选项有误
This commit is contained in:
sw 2015-01-16 10:43:05 +08:00
parent f41cd0a8ab
commit 9fb0275563
3 changed files with 19 additions and 3 deletions

View File

@ -122,7 +122,7 @@ class PollController < ApplicationController
################处理选项 ################处理选项
if params[:question_answer] if params[:question_answer]
@poll_question.poll_answers.each do |answer| @poll_question.poll_answers.each do |answer|
@poll_question.poll_answers.destroy answer unless params[:question_answer].keys.include? answer.id.to_s answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
end end
for i in 1..params[:question_answer].count for i in 1..params[:question_answer].count
question = @poll_question.poll_answers.find_by_id params[:question_answer].keys[i-1] question = @poll_question.poll_answers.find_by_id params[:question_answer].keys[i-1]

View File

@ -0,0 +1,12 @@
<tbody>
<% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %>
<tr>
<td>
<label>
<input class="ur_radio" type="radio" name="<%= poll_question %>" value="<%= poll_answer.answer_text%>" >
<%= poll_answer.answer_text%>
</label>
</td>
</tr>
<% end %>
</tbody>

View File

@ -1,2 +1,6 @@
$("#poll_questions_<%= @poll_question.id%>").html("<div id='show_poll_questions_<%= @poll_question.id %>'>" +
pollQuestionCancel(<%= @poll_question.id%>); "<%= escape_javascript(render :partial => 'show_MC', :locals => {:poll_question => @poll_question}) %>" +
"</div>" +
"<div id='edit_poll_questions_<%= @poll_question.id %>' style='display: none;'>" +
"<%= escape_javascript(render :partial => 'edit_MC', :locals => {:poll_question => @poll_question}) %>" +
"</div>");