课程留言的回复防止多次提交

This commit is contained in:
cxt 2016-05-13 14:33:06 +08:00
parent 979598f334
commit 402976cf40
3 changed files with 14 additions and 7 deletions

View File

@ -36,7 +36,7 @@
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_' name="new_form[course_message]"></textarea> <textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_' name="new_form[course_message]"></textarea>
<p nhname='contentmsg_'></p> <p nhname='contentmsg_'></p>
<a id="new_message_cancel_btn_" href="javascript:void(0)" class="grey_btn fr mt10">取消</a> <a id="new_message_cancel_btn_" href="javascript:void(0)" class="grey_btn fr mt10">取消</a>
<a href="javascript:void(0);" class="blue_btn fr ml10 mt10" id="submit_feedback_course" >留言</a> <a href="javascript:void(0);" class="blue_btn fr ml10 mt10" id="new_message_submit_btn_" >留言</a>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
@ -55,9 +55,6 @@
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
$("#submit_feedback_course").one('click',function() {
$("#course_feedback_new").submit();
});
KindEditor.ready(function(K){ KindEditor.ready(function(K){
$("a[nhname='reply_btn']").live('click',function(){ $("a[nhname='reply_btn']").live('click',function(){
var params = {}; var params = {};
@ -68,6 +65,7 @@
params.textarea = $("textarea[name='user_notes']",params.div_form); params.textarea = $("textarea[name='user_notes']",params.div_form);
params.contentmsg = $("p[nhname='contentmsg']",params.div_form); params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
params.submit_btn = $("input[nhname='submit_btn']",params.div_form);
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form); params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
params.height = 55; params.height = 55;
if(params.textarea.data('init') == undefined){ if(params.textarea.data('init') == undefined){
@ -76,6 +74,9 @@
params.cancel_btn.click(function(){ params.cancel_btn.click(function(){
nh_reset_form(params); nh_reset_form(params);
}); });
params.submit_btn.one('click', function () {
params.form.submit();
});
} }
params.cancel_btn.click(); params.cancel_btn.click();
toggleAndSettingWordsVal(params.div_form, params.textarea); toggleAndSettingWordsVal(params.div_form, params.textarea);

View File

@ -12,7 +12,8 @@
<%= hidden_field_tag 'show_name',params[:show_name],:value => show_name.nil? ? true : show_name %> <%= hidden_field_tag 'show_name',params[:show_name],:value => show_name.nil? ? true : show_name %>
<div class="fl" style="padding-top:5px;" nhname="toolbar_container"></div> <div class="fl" style="padding-top:5px;" nhname="toolbar_container"></div>
<%= submit_tag l(:button_feedback_respond), :name => nil , <input nhname="submit_btn" type="button" class="reply_btn" value="<%=l(:button_feedback_respond) %>"/>
<%#= submit_tag l(:button_feedback_respond), :name => nil ,
:class => "reply_btn"%> :class => "reply_btn"%>
<input nhname="cancel_btn" type="button" style="display:none;"/> <input nhname="cancel_btn" type="button" style="display:none;"/>
<% end %> <% end %>

View File

@ -49,6 +49,9 @@ function nh_check_field(params){
if(params.content.isEmpty()){ if(params.content.isEmpty()){
params.contentmsg.html('内容不能为空'); params.contentmsg.html('内容不能为空');
params.contentmsg.css({color:'#ff0000'}); params.contentmsg.css({color:'#ff0000'});
params.submit_btn.one('click', function(){
params.form.submit();
});
}else{ }else{
params.contentmsg.html('填写正确'); params.contentmsg.html('填写正确');
params.contentmsg.css({color:'#008000'}); params.contentmsg.css({color:'#008000'});
@ -68,7 +71,9 @@ function init_form(params){
issubmit:true, issubmit:true,
content:params.editor, content:params.editor,
contentmsg:params.contentmsg, contentmsg:params.contentmsg,
textarea:params.textarea textarea:params.textarea,
submit_btn:params.submit_btn,
form:params.form
}); });
if(is_checked){ if(is_checked){
if(flag){ if(flag){
@ -115,7 +120,7 @@ function init_KindEditor_data(id){
params.cancel_btn.click(function () { params.cancel_btn.click(function () {
nh_reset_form(params); nh_reset_form(params);
}); });
params.submit_btn.click(function () { params.submit_btn.one('click', function () {
params.form.submit(); params.form.submit();
}); });
params.textarea.data('init', 1); params.textarea.data('init', 1);