[英]Animating the first element of a PrimeFaces Datatable
我已經在dataTable中加載了一個帖子列表,並且有一個表格可以將新帖子添加到“牆”中。
我想做類似Facebook牆的操作,因此,當我插入新的帖子時,我希望它出現時具有褪色效果。
我嘗試使用PrimeFaces的效果,但是它將效果應用到整個DataTable,因此我想到了使用簡單的JQuery腳本,但是我不知道該怎么做。
這是我上次嘗試的簡單代碼(無效!):
<script type="text/javascript">
function animateNewPost(id) {
jQuery('#post_' +id).effect("slide", { direction: "right" }, 2000);
}
</script>
[cut]
<p:commandLink ajax="true" action="#{postBean.insertPost(loginBean.user)}" value="Insert Post" update=":postMessage, :postList, :postForm" oncomplete="animateNewPost(#{lazyPostBean.posts.get(0).getIdPost()})"/>
[cut]
<p:dataTable id="postTable" var="post" value="#{lazyPostBean.posts}">
<p:column style="border: 0px; background: rgba(0,0,0,0);">
<div class="feature">
<div class="post_#{post.idPost}">
[POST CONTENT]
</div>
</div>
</p:column>
</p:dataTable>
我該怎么辦?
編輯:id已正確傳遞給javascript函數,並且Post的div的HTML輸出是
<div class="post_24">
所以我想這是對的。
首先,您應該從#
修復您的jquery選擇器,該選擇器旨在將元素的ID插入.
(單點)引用此類jQuery('.post_
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.