问卷编辑页面在发布问卷和点击问卷标题确认增加问卷标题不能为空的提示

This commit is contained in:
sw 2015-01-23 14:25:29 +08:00
parent 016f4f9a0d
commit dbdae2ac7e
4 changed files with 24 additions and 13 deletions

View File

@ -70,8 +70,8 @@ class PollController < ApplicationController
end
def update
@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]
@poll.polls_name = params[:polls_name]
@poll.polls_description = params[:polls_description]
if @poll.save
respond_to do |format|
format.js

View File

@ -7,7 +7,7 @@
<textarea name="polls_description" maxlength="300" id="polls_description" class="textarea_editor"><%= @poll.polls_description%></textarea>
</div>
<div class="ur_editor_footer">
<a class="btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().submit();">确定</a>
<a class="btn_submit" data-button="ok" onclick="pollsSubmit($(this));">确定</a>
<a class="btn_cancel" data-button="cancel" onclick="pollsCancel();">取消</a>
</div>
<div class="cl"></div>

View File

@ -25,6 +25,10 @@
}
//问卷头
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
function pollsSubmit(doc){
var title = $.trim($("#polls_title").val());
if(title.length == 0){alert("问卷标题不能为空");}else{doc.parent().parent().parent().submit();}
}
function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();}
//
function pollQuestionCancel(question_id){
@ -57,15 +61,22 @@
function poll_submit()
{
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'poll_submit', locals: { :poll => @poll,:is_remote => false}) %>');
showModal('ajax-modal', '310px');
$('#ajax-modal').css('height','115px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='#' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().removeClass("alert_praise");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");
var title = $.trim($("#polls_name_h").html());
if(title.length == 0)
{
alert("问卷标题不能为空");
}
else{
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'poll_submit', locals: { :poll => @poll,:is_remote => false}) %>');
showModal('ajax-modal', '310px');
$('#ajax-modal').css('height','115px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='#' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().removeClass("alert_praise");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");
}
}
</script>
</head>

View File

@ -1,7 +1,7 @@
<div class="ur_page_head ur_editor02"><!--头部显示 start-->
<a href="#" class="ur_icon_edit" title="编辑" onclick="pollsEdit();"></a>
<h1 class="ur_page_title" id="polls_name_h">
<%= poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name%>
<%= poll.polls_name%>
</h1>
<p class="ur_prefix_content" id="polls_description_p">
<%= @poll.polls_description%>