我坚持使用Dojo来实现这一目标。基本上我想要实现的是一个AJAX功能,用户在博客帖子中添加评论并立即显示。
所以我到了dojo.xhrPost
接收一大块需要添加到评论列表的html的地步。现在我想慢慢淡出新评论,这样效果就不那么刺耳了。
这是我到目前为止所得到的:
function displayNewComment(commentHtml)
{
//place new comment html at the end of the list
dojo.place(commentHtml, dojo.byId('Comments'), "last");
//is there any way to fade this in?
}
答案 0 :(得分:2)
我假设您使用dojo.create
来创建新节点。
在dojo.create中,您可以将节点的opacity
设置为0
,这样就不会显示。
var commentHtml = dojo.create('div', { style:”opacity:0”, innerHTML: data});
dojo.place(commentHtml, dojo.byId('Comments'), "last");
或直接
var commentHtml = dojo.create(
'div',
{ style:”opacity:0”, innerHTML: data},
dojo.byId('Comments'),
"last"
);
如果您构建节点,则只需将opacity
设置为0
。
修改强>
当然,用
淡出它dojo.fadeIn(commentHTML, duration, easingFunc);
更多信息:
http://api.dojotoolkit.org/jsdoc/1.4/dojo.create