1、修改标题头、取消修改标题头数据的保存和页面的变更

Poll
sw 11 years ago
parent 99ffc8a643
commit 20c160f03f

@ -60,12 +60,14 @@ class PollController < ApplicationController
end end
def update def update
@poll.polls_name = params[:polls_name] @poll.polls_name = params[:polls_name].empty? ? l(:label_poll_title) : params[:polls_name]
@poll.polls_description = params[:polls_description].empty? ? l(:label_poll_description) : params[:polls_description]
if @poll.save if @poll.save
respond_to do |format| respond_to do |format|
format.html { redirect_to poll_index_url(:polls_type => @course.class.to_s, :polls_group_id => @course.id) } format.js
end end
else else
render_404
end end
end end
@ -98,7 +100,7 @@ class PollController < ApplicationController
answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
question_option = { question_option = {
:answer_position => i, :answer_position => i,
:answer_text => params[:question_answer].values[i-1] :answer_text => answer
} }
@poll_questions.poll_answers.new question_option @poll_questions.poll_answers.new question_option
end end

@ -1,21 +1,15 @@
<script type="text/javascript"> <%= form_for @poll,:remote => true do |f|%>
function regexPollsTitle() <div class="ur_editor ur_title_editor"> <!--编辑头部start-->
{ <div class="ur_title_editor_title">
var polls_title = $.trim($("#polls_title").val()); <input type="text" name="polls_name" id="polls_title" value="<%= @poll.polls_name %>" class="input_title" placeholder="问卷标题"/>
alert(polls_title); </div>
} <div class="ur_title_editor_prefix">
</script> <textarea name="polls_description" class="textarea_editor"><%= @poll.polls_description%></textarea>
<div class="ur_editor ur_title_editor"> <!--编辑头部start--> </div>
<div class="ur_title_editor_title"> <div class="ur_editor_footer">
<input type="text" name="title" id="polls_title" class="input_title" placeholder="问卷标题" onkeyup="regexPollsTitle();"/> <a class="btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
</div> <a class="btn_cancel" data-button="cancel" onclick="pollsCancel();">取消</a>
<div class="ur_title_editor_prefix"> </div>
<textarea name="prefix" class="textarea_editor" placeholder="问卷描述"> <div class="cl"></div>
</textarea> </div><!--编辑头部 end-->
</div> <% end%>
<div class="ur_editor_footer">
<a class="btn_submit" data-button="ok">确定</a>
<a class="btn_cancel" data-button="cancel">取消</a>
</div>
<div class="cl"></div>
</div><!--编辑头部 end-->

@ -10,6 +10,11 @@
function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_MCQ') %>");} function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_MCQ') %>");}
function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_single') %>");} function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_single') %>");}
function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_mulit') %>");} function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_mulit') %>");}
//问卷头
function pollsCancel()
{
$("#polls_head").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:poll => @poll}) %>");
}
//单选题 //单选题
function add_single_answer(doc) function add_single_answer(doc)
{ {
@ -60,7 +65,10 @@
<div class="cl"></div> <div class="cl"></div>
</div><!--选项 end--> </div><!--选项 end-->
<%= render :partial => 'edit_head'%> <div id="polls_head">
<%#= render :partial => 'show_head', :locals => {:poll => @poll} %>
<%= render :partial => 'edit_head', :locals => {:poll => @poll}%>
</div>
<div> <div>
<% @poll.poll_questions.each do |poll_question|%> <% @poll.poll_questions.each do |poll_question|%>

@ -1,8 +1,10 @@
<div class="ur_page_head ur_editor02" ><!--头部显示 start--> <div class="ur_page_head ur_editor02"><!--头部显示 start-->
<h1 class="ur_page_title">标题标题标题标题标题标题标题</h1>
<p class="ur_prefix_content">描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述描述
描述描述描述描述描述描述描述描述描述描述描述描述
</p>
<a href="#" class="ur_icon_edit" title="编辑"></a> <a href="#" class="ur_icon_edit" title="编辑"></a>
<h1 class="ur_page_title">
<%= poll.polls_name%>
</h1>
<p class="ur_prefix_content">
<%= @poll.polls_description%>
</p>
<div class="cl"></div> <div class="cl"></div>
</div><!--头部显示 end--> </div><!--头部显示 end-->

@ -0,0 +1 @@
$("#polls_head").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:poll => @poll}) %>");

@ -2251,5 +2251,7 @@ zh:
label_mulit: 多行文字 label_mulit: 多行文字
label_enter_single_title: 请输入单选题标题 label_enter_single_title: 请输入单选题标题
label_new_answer: 新建选项 label_new_answer: 新建选项
label_poll_title: 问卷标题
label_poll_description: 问卷描述

Loading…
Cancel
Save