0
問題,我有以下代碼:我的jQuery ...項目正在消失
<div id="comments">
<h2>
Comments</h2>
<div id="comment">
</div>
<% foreach (var comment in this.Model.Topic.TopicComments.OrderBy(tc => tc.CreatedDate).Reverse())
{ %>
<% this.Html.RenderPartial("TopicComment", comment); %>
<% } %>
<fieldset>
<% using (Ajax.BeginForm("AddComment", "Topic", new { id = this.Model.Topic.TopicId },
new AjaxOptions { UpdateTargetId = "comment", OnSuccess = "animateTopicComment" }))
{ %>
<%= Html.TextArea("Body", string.Empty, new { @class = "wmd-ignore" })%>
<input type="submit" value="Add Comment" />
<% } %>
</fieldset>
</div>
<script type="text/javascript">
function animateTopicComment() {
$("#comment").fadeOut(0, function() {
$('#comment').fadeIn("slow");
});
$("#Body").val("");
}
</script>
我所試圖做的是,每當用戶添加了一個評論,我想評論淡入此差不多。作品...保存爲以下問題:
如果我不斷添加評論,無論在評論DIV被覆蓋。如果我不使用任何jQuery動畫,則新評論將正確顯示。
這將工作......愚蠢的問題......你會如何追加它? – mattruma 2009-11-10 13:00:04
這不是一個愚蠢的問題。你會使用append關鍵字。所以我們假設你有一個div,它有一個類名「MyContent」。所有你需要做的就是從你的jQuery post中返回的html並說出類似$('。MyContent')。append(html);因爲它的doco在這裏http://docs.jquery.com/Manipulation/append – griegs 2009-11-10 20:48:24
因此,而不是在我的Ajax調用中使用UpdateTargetId,我會做所有這一切在一個單獨的功能? – mattruma 2009-11-11 14:29:51