diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 191968183..48b1af43a 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -120,7 +120,8 @@ class PollController < ApplicationController #删除单选题 def delete_poll_question @poll_question = PollQuestion.find params[:poll_question] - poll_questions = @poll_question.poll.poll_questions.where("question_number > #{@poll_question.question_number}") + @poll = @poll_question.poll + poll_questions = @poll.poll_questions.where("question_number > #{@poll_question.question_number}") poll_questions.each do |question| question.question_number -= 1 question.save diff --git a/app/views/poll/_poll_content.html.erb b/app/views/poll/_poll_content.html.erb new file mode 100644 index 000000000..6c2e61215 --- /dev/null +++ b/app/views/poll/_poll_content.html.erb @@ -0,0 +1,10 @@ +<% poll.poll_questions.each do |poll_question|%> +
+
+ <%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %> +
+ +
+<% end %> \ No newline at end of file diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb index 1387bdd02..04d8e2f6e 100644 --- a/app/views/poll/_poll_form.html.erb +++ b/app/views/poll/_poll_form.html.erb @@ -96,16 +96,7 @@
- <% @poll.poll_questions.each do |poll_question|%> -
-
- <%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %> -
- -
- <% end %> + <%= render :partial => 'poll_content', :locals => {:poll => @poll}%>
diff --git a/app/views/poll/delete_poll_question.js.erb b/app/views/poll/delete_poll_question.js.erb index ad8fe7674..85057e550 100644 --- a/app/views/poll/delete_poll_question.js.erb +++ b/app/views/poll/delete_poll_question.js.erb @@ -1 +1 @@ -$("#poll_questions_<%= @poll_question.id%>").remove(); \ No newline at end of file +$("#poll_content").html("<%= escape_javascript(render :partial => 'poll_content', :locals => {:poll => @poll}) %>"); \ No newline at end of file