删除某一题目后,后面的题目序号自动-1,以及页面js的刷新
This commit is contained in:
parent
3fab26214f
commit
5ec2789881
|
@ -120,7 +120,8 @@ class PollController < ApplicationController
|
||||||
#删除单选题
|
#删除单选题
|
||||||
def delete_poll_question
|
def delete_poll_question
|
||||||
@poll_question = PollQuestion.find params[: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|
|
poll_questions.each do |question|
|
||||||
question.question_number -= 1
|
question.question_number -= 1
|
||||||
question.save
|
question.save
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<% poll.poll_questions.each do |poll_question|%>
|
||||||
|
<div id="poll_questions_<%= poll_question.id%>">
|
||||||
|
<div id="show_poll_questions_<%= poll_question.id %>">
|
||||||
|
<%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
|
||||||
|
</div>
|
||||||
|
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
|
||||||
|
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -96,16 +96,7 @@
|
||||||
|
|
||||||
<!-- 问题 -->
|
<!-- 问题 -->
|
||||||
<div id="poll_content">
|
<div id="poll_content">
|
||||||
<% @poll.poll_questions.each do |poll_question|%>
|
<%= render :partial => 'poll_content', :locals => {:poll => @poll}%>
|
||||||
<div id="poll_questions_<%= poll_question.id%>">
|
|
||||||
<div id="show_poll_questions_<%= poll_question.id %>">
|
|
||||||
<%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
|
|
||||||
</div>
|
|
||||||
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
|
|
||||||
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 新增问题 -->
|
<!-- 新增问题 -->
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
$("#poll_questions_<%= @poll_question.id%>").remove();
|
$("#poll_content").html("<%= escape_javascript(render :partial => 'poll_content', :locals => {:poll => @poll}) %>");
|
Loading…
Reference in New Issue