修复创建贴吧时,提示“贴吧名称已经存在”,实际又新建成功了 的问题 app/views/forums/index.html.erb

liuyizhou
liuyizhou 9 years ago committed by louant
parent 0a82de1cf4
commit 0ed26310e3

@ -28,6 +28,7 @@
} }
} }
$(function() { $(function() {
hideError();
$("#complex").click(function(){ $("#complex").click(function(){
$("#reorder_popu").removeClass("sortArrowActiveU"); $("#reorder_popu").removeClass("sortArrowActiveU");
$("#reorder_popu").removeClass("sortArrowActiveD"); $("#reorder_popu").removeClass("sortArrowActiveD");
@ -71,10 +72,11 @@
e.preventDefault(); e.preventDefault();
} }
}) })
}); });
function check_and_submit(doc){ function check_and_submit(doc){
$("#error").html('').hide(); $("#error").html("").hide();
check_forum_name(); // check_forum_name();
if( $("textarea[name='forum[name]']").val().trim() == "" && $("textarea[name='forum[description]']").val().trim() != "" ){ if( $("textarea[name='forum[name]']").val().trim() == "" && $("textarea[name='forum[description]']").val().trim() != "" ){
$("#error").html("名称不能为空").show(); $("#error").html("名称不能为空").show();
return; return;
@ -91,17 +93,20 @@
} }
var check_pass = true; var check_pass = true;
function check_forum_name(){ function check_forum_name(){
$("#error").html("").hide();
check_pass = true; check_pass = true;
name = $("textarea[name='forum[name]']").val().trim(); name = $("textarea[name='forum[name]']").val().trim();
alert(name)
if( name != ""){ if( name != ""){
$.get( $.get(
'<%= check_forum_name_forums_path %>', '<%= check_forum_name_forums_path %>',
{"forum_name":encodeURIComponent(name)}, {"forum_name":encodeURIComponent(name)},
function(data){ function(data){
alert(data)
if( data == 'true'){ if( data == 'true'){
$("#error").html("贴吧名称已经存在").show(); $("#error").html("贴吧名称已经存在").show();
check_pass = false; check_pass = false;
return false;
} }
} }
); );

Loading…
Cancel
Save