使用AJAX刷新时获得div的高度错误

时间:2013-08-02 15:50:10

标签: jquery ajax jquery-animate height innerhtml

当用户编写评论时,我有一个通过Ajax更新的评论框。另外,该列表是可扩展的,通常使用jQuery动画进行扩展/折叠。

简短的结构性例子:

<div id="comm_holder">
// the container, that will be expanded/collapsed (overflow:hidden)
   <div id="comm_list">
      // Comment 1 (all comments might have a attached image too)
      // Comment 2
      // etc..
   </div>
</div>

所以现在我通过Ajax刷新List,然后php返回新的HTML代码。用“html”写给div ......

$("#art_comm").html(ajaxRequest.responseText);

...但是然后尝试检索div的新高度会返回一个小于它的值。 (尝试过高度,outerHeight,outerHeight(真)等等......)

$("#art_comments_"+id_art).outerHeight(true));
// returns some 30 to 60 px less at this very first moment (not even some number that makes somehow sense because a full row snt rendred etc...)

仅在新评论附加图像时才会出现。但是当我设置超过100毫秒的超时或手动调用扩展时,高度是正确的。

我的想法:高度返回“一半”,并且图像在第一秒没有正确渲染或放置(没有浮动,所有内联块)。

当我发出警报时,也可以正常工作,所以这对我来说必定是一些时间问题。

关于这个奇怪的东西的任何想法?

先谢谢你的欢呼声, 菲尔

0 个答案:

没有答案