贴吧名称 和描述输入的时候自适应高度

This commit is contained in:
lizanle 2015-09-21 09:59:41 +08:00
parent 67fe8de897
commit 52b4cba582
1 changed files with 14 additions and 4 deletions

View File

@ -1,3 +1,4 @@
<%= javascript_include_tag 'new_user' %>
<script> <script>
function add_class(id){ function add_class(id){
if($("#"+id).hasClass("sortArrowActiveD")){ if($("#"+id).hasClass("sortArrowActiveD")){
@ -47,11 +48,12 @@
$("#reorder_popu").removeClass("sortArrowActiveD"); $("#reorder_popu").removeClass("sortArrowActiveD");
add_class("reorder_time"); add_class("reorder_time");
}); });
}); });
function check_and_submit(doc){ function check_and_submit(doc){
$("#error").html('').hide(); $("#error").html('').hide();
check_forum_name(); check_forum_name();
if( $("input[name='forum[name]']").val().trim() == "" || $("input[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;
}else{ }else{
@ -61,7 +63,7 @@
var check_pass = true; var check_pass = true;
function check_forum_name(){ function check_forum_name(){
check_pass = true; check_pass = true;
name = $("input[name='forum[name]']").val().trim(); name = $("textarea[name='forum[name]']").val().trim();
if( name != ""){ if( name != ""){
$.get( $.get(
'<%= check_forum_name_forums_path %>', '<%= check_forum_name_forums_path %>',
@ -89,10 +91,18 @@
<div class="red fl mb10" id="error" style="display: none">error</div> <div class="red fl mb10" id="error" style="display: none">error</div>
<%= form_tag({:controller => 'forums',:action=>'create',:format=>'js'},:method => 'post',:remote=>'true') do |f| %> <%= form_tag({:controller => 'forums',:action=>'create',:format=>'js'},:method => 'post',:remote=>'true') do |f| %>
<div class="mt15"> <div class="mt15">
<input type="text" name="forum[name]" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" /> <textarea type="text" name="forum[name]" id="forum_name" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" ></textarea>
<script>
var textarea = document.getElementById('forum_name');
autoTextarea(textarea);
</script>
</div> </div>
<div class="mt15"> <div class="mt15">
<input type="text" name="forum[description]" class="postCreateInput" placeholder="输入贴吧描述" /> <textarea type="text" name="forum[description]" id="forum_desc" class="postCreateInput" placeholder="输入贴吧描述"></textarea>
<script>
var textarea1 = document.getElementById('forum_desc');
autoTextarea(textarea1);
</script>
</div> </div>
<div class="mt10"> <div class="mt10">
<div class="fr"><a href="javascript:void(0);" class="submit_btn" onclick="check_and_submit($(this));">确定</a></div> <div class="fr"><a href="javascript:void(0);" class="submit_btn" onclick="check_and_submit($(this));">确定</a></div>