socialforge/app/views/forums/_edit.html.erb

55 lines
2.0 KiB
Plaintext
Raw Normal View History

2016-12-30 11:30:40 +08:00
<div style="width:460px;">
<div class="sy_popup_top">
<h3 class="fl">新建贴吧</h3>
<a href="javascript:void(0);" class="sy_icons_close fr" onclick="hideModal()"></a>
<div class="cl"></div>
</div>
<div class="muban_popup_con mt15" >
<%= labelled_form_for @forum, :html => {:id => "forum_new"} do |f| %>
2016-12-30 13:47:31 +08:00
<%= render :partial => "forums/form", :locals => {:f => f} %>
2016-12-30 11:30:40 +08:00
<% end %>
<%#= form_tag({:controller => 'forums', :action => 'create'}, :method => 'post', :id => "forum_new") do |f| %>
<%# end %>
</div>
</div>
<script>
function forums_commit(){
$("#forum_name_error_tips").hide();
$("#forum_description_error_tips").hide();
if ($("#forum_name").val().trim() == ""){
$("#forum_name_error_tips").html("贴吧名称不能为空").show();
}
else if($("#forum_desc").val().trim() == ""){
$("#forum_description_error_tips").html("贴吧描述不能为空").show();
}
else if($("#forum_desc").val().length > 5000){
$("#forum_description_error_tips").html("贴吧描述不能超过5000个字符").show();
}
else{
$.ajax({
url:'<%= check_forum_name_forums_path %>',
type:'get',
data:{
forum_name:$("#forum_name").val().trim()
},
success:function(data){
if(data.result == true){
alert("提交成功");
$("#forum_new").submit();
hideModal();
return true;
}else{
alert("提交失败");
$("#forum_name_error_tips").html("贴吧名称已存在").show();
return false;
}
},
error:function(){
alert('请检查当前网络连接')
}
});
}
}
</script>