课程/项目留言:快速点击提交按钮重复产生多条记录的问题

This commit is contained in:
cxt 2016-05-18 10:57:56 +08:00
parent 357e143c9a
commit 28edaf2246
6 changed files with 41 additions and 29 deletions

View File

@ -1,12 +1,12 @@
source 'https://rubygems.org/'
### 这里执行bundle config mirror.https://rubygems.org https://gems.ruby-china.org 切换到ruby-china源
### <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>bundle config mirror.https://rubygems.org https://gems.ruby-china.org <20>л<EFBFBD><D0BB><EFBFBD>ruby-chinaԴ
unless RUBY_PLATFORM =~ /w32/
# unix-like only
gem 'iconv'
end
gem 'certified'
#gem 'certified'
gem 'wechat',path: 'lib/wechat'
gem 'grack', path:'lib/grack'

View File

@ -36,7 +36,7 @@
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_' name="new_form[course_message]"></textarea>
<p nhname='contentmsg_'></p>
<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 %>
</div>
<% end %>
@ -55,9 +55,6 @@
<script type="text/javascript">
$(function(){
$("#submit_feedback_course").one('click',function() {
$("#course_feedback_new").submit();
});
KindEditor.ready(function(K){
$("a[nhname='reply_btn']").live('click',function(){
var params = {};
@ -68,15 +65,18 @@
params.textarea = $("textarea[name='user_notes']",params.div_form);
params.contentmsg = $("p[nhname='contentmsg']",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.height = 55;
if(params.textarea.data('init') == undefined){
params.editor = init_editor(params);
init_form(params);
params.cancel_btn.click(function(){
nh_reset_form(params);
});
}
params.editor = init_editor(params);
init_form(params);
params.cancel_btn.click(function(){
nh_reset_form(params);
});
params.submit_btn.one('click', function () {
params.form.submit();
});
params.textarea.data('init',1);
params.cancel_btn.click();
toggleAndSettingWordsVal(params.div_form, params.textarea);
setTimeout(function(){
@ -86,7 +86,6 @@
params.textarea.hide();
}
},300);
params.textarea.data('init',1);
});
});
});

View File

@ -80,6 +80,9 @@
if(params.content.isEmpty()){
params.contentmsg.html('内容不能为空');
params.contentmsg.css({color:'#ff0000'});
params.submit_btn.one('click', function(){
params.form.submit();
});
}else{
params.contentmsg.html('填写正确');
params.contentmsg.css({color:'#008000'});
@ -124,7 +127,9 @@
issubmit:true,
content:params.editor,
contentmsg:params.contentmsg,
textarea:params.textarea
textarea:params.textarea,
submit_btn:params.submit_btn,
form:params.form
});
if(is_checked){
if(flag){
@ -161,13 +166,15 @@
params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
if(params.textarea.data('init') == undefined){
params.editor = init_editor(params);
init_form(params);
params.cancel_btn.click(function(){
nh_reset_form(params);
});
}
params.submit_btn = $("input[nhname='submit_btn']",params.div_form);
params.editor = init_editor(params);
init_form(params);
params.submit_btn.one('click', function () {
params.form.submit();
});
params.cancel_btn.click(function(){
nh_reset_form(params);
});
params.cancel_btn.click();
toggleAndSettingWordsVal(params.div_form, params.textarea);
setTimeout(function(){

View File

@ -12,8 +12,8 @@
<%= 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>
<!--<input nhname="submit_btn" type="button" class="reply_btn" value="<%#=l(:button_feedback_respond) %>"/>-->
<%= 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"%>
<input nhname="cancel_btn" type="button" style="display:none;"/>
<% end %>

View File

@ -11,7 +11,8 @@
<%= 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>
<%= 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"%>
<input nhname="cancel_btn" type="button" style="display:none;"/>

View File

@ -1,5 +1,5 @@
function init_editor(params){
// var minHeight; //最小高度
// var minHeight; //最小高度
var paramsHeight = params.height; //设定的高度
var paramsWidth = params.width == undefined ? "100%" : params.width;
@ -7,7 +7,7 @@ function init_editor(params){
resizeType : 1,minWidth:"1px",width:paramsWidth,
height:"30px",// == undefined ? "30px":paramsHeight+"px",
minHeight:"30px",// == undefined ? "30px":paramsHeight+"px",
items:['emoticons'],
items:['emoticons'],
afterChange:function(){//按键事件
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
var edit = this.edit;
@ -49,6 +49,9 @@ function nh_check_field(params){
if(params.content.isEmpty()){
params.contentmsg.html('内容不能为空');
params.contentmsg.css({color:'#ff0000'});
params.submit_btn.one('click', function(){
params.form.submit();
});
}else{
params.contentmsg.html('填写正确');
params.contentmsg.css({color:'#008000'});
@ -68,7 +71,9 @@ function init_form(params){
issubmit:true,
content:params.editor,
contentmsg:params.contentmsg,
textarea:params.textarea
textarea:params.textarea,
submit_btn:params.submit_btn,
form:params.form
});
if(is_checked){
if(flag){
@ -115,7 +120,7 @@ function init_KindEditor_data(id){
params.cancel_btn.click(function () {
nh_reset_form(params);
});
params.submit_btn.click(function () {
params.submit_btn.one('click', function () {
params.form.submit();
});
params.textarea.data('init', 1);