2010-05-08 100 views
0

我在網站上製作了一大串圖片的圖片網站,每張圖片下面都有可能評論圖片,然後在沒有頁面加載和評論內容的情況下顯示評論,問題是當我有很長的評論打破當前行,他們不顯示,因爲我的評論框CSS溢出隱藏。下面是例子:多行註釋問題jquery

這是一個註釋 - 這是顯示 正確
這是一個註釋這是一個 評論這是一個註釋 - 這是 ,因爲它打破無法正常

顯示線。下面是該jQuery代碼:

$.ajax({ 
    type: "POST", 
    url: "<?=base_url()?>imagesform/post_comment", 
    data: datas, 
    success: function() { 
     $("#image-comments-" + image_id).attr("class", "comments"); 
     $("#image-comments-" + image_id).append("<li id=\"new_append_" + image_id+ "\">" + $("#image").find(".comment").val() + "</li>").children(':last').height($('.comments li:last').height()).hide().slideDown(500, function() { 
      var bodyHeight = $('html').height(); 
      $('.addComment').fadeOut(300, function() { 
       $('html').height(bodyHeight); 
      }); 
     }); 
     alert($("#image").find(".comment").val()); 
    } 

}); 

這裏$("#image").find(".comment").val()在其評論輸入,當我提醒它整個多行輸入的文本區域的價值在那裏把它的不被追加到李正確,這是我感到困惑時的一部分,任何建議爲什麼只有部分輸入的字符串被附加?

回答

2

這就是答案,高度上當了因爲某些原因:

$("#image-comments-" + image_id).append("<li id=\"new_append_" + image_id+ "\" style=\"height:auto !important;\">" 

新增height:auto !important; CSS屬性爲新創建的李

0

對我來說就像你想用<br>替換換行符來通過HTML顯示它們。

alert($("#image").find(".comment").val().replace('\n', '<br>')); 
+0

我已經試過了吧 – ant 2010-05-08 09:34:05