增加修改单选题的路由、action、以及js

This commit is contained in:
sw 2015-01-15 18:17:45 +08:00
parent 5ec2789881
commit d55492b07a
4 changed files with 35 additions and 32 deletions

View File

@ -114,7 +114,12 @@ class PollController < ApplicationController
#修改单选题 #修改单选题
def update_poll_question def update_poll_question
a = 1 @poll_question = PollQuestion.find params[:poll_question]
@poll = @poll_question.poll
respond_to do |format|
format.js
end
end end
#删除单选题 #删除单选题

View File

@ -1,33 +1,31 @@
<%= form_for poll_question,:url =>update_poll_question_poll_path(@poll.id),:remote => true do |f|%> <%= form_for(poll_question,:url => update_poll_question_poll_index_path(:poll_question => poll_question.id),:remote => true) do |f|%>
<div> <!--编辑单选start-->
<!--编辑单选start--> <div class="ur_editor radio">
<div class="ur_editor radio"> <div class="ur_editor_title">
<div class="ur_editor_title"> <label>问题:&nbsp;&nbsp;</label>
<label>问题:&nbsp;&nbsp;</label> <input type="hidden" name="question_type" value="<%= poll_question.question_type%>"/>
<input type="hidden" name="question_type" value="<%= poll_question.question_type%>"/> <input class="ur_question_title" type="text" name="poll_questions_title" id="poll_questions_title_<%=poll_question.id%>" placeholder="请输入单选题标题" value="<%= poll_question.question_title%>"/>
<input class="ur_question_title" type="text" name="poll_questions_title" id="poll_questions_title_<%=poll_question.id%>" placeholder="请输入单选题标题" value="<%= poll_question.question_title%>"/> <input type="checkbox" name="is_necessary" value="true" <%= poll_question.is_necessary == 1 ? "checked" : ""%>/>
<input type="checkbox" name="is_necessary" value="true" <%= poll_question.is_necessary == 1 ? "checked" : ""%>/> <label>必答</label>
<label>必答</label>
</div>
<div class="ur_editor_content">
<ul>
<% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %>
<li class='ur_item'>
<label>选项<span class='ur_index'></span></label>
<input type='text' name='question_answer[<%= poll_answer.id %>]' placeholder='新建选项' value="<%= poll_answer.answer_text%>"/>
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
</li>
<div class='cl'></div>
<% end%>
</ul>
</div>
<div class="ur_editor_footer">
<a class="btn btn_dark btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().parent().submit();">确定</a>
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="pollQuestionCancel(<%= poll_question.id%>);">取消</a>
</div>
<div class="cl"></div>
</div> </div>
<!--编辑单选 end--> <div class="ur_editor_content">
<ul>
<% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %>
<li class='ur_item'>
<label>选项<span class='ur_index'></span></label>
<input type='text' name='question_answer[<%= poll_answer.id %>]' placeholder='新建选项' value="<%= poll_answer.answer_text%>"/>
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
</li>
<div class='cl'></div>
<% end%>
</ul>
</div>
<div class="ur_editor_footer">
<a class="btn btn_dark btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="pollQuestionCancel(<%= poll_question.id%>);">取消</a>
</div>
<div class="cl"></div>
</div> </div>
<!--编辑单选 end-->
<% end%> <% end%>

View File

@ -62,10 +62,10 @@ RedmineApp::Application.routes.draw do
member do member do
get 'statistics_result' get 'statistics_result'
post 'create_poll_question' post 'create_poll_question'
post 'update_poll_question'
end end
collection do collection do
delete 'delete_poll_question' delete 'delete_poll_question'
post 'update_poll_question'
end end
end end