jQuery FadeOut div 有效 - .load 然后 .fadeIn div 无效
我正在开发一个 WordPress 3.0 主题,这是我的第一个带有一些 jQuery 增强功能的主题。我正在尝试淡出和淡入每个帖子区域的分页。这个想法是,当用户单击“上一页”或“下一页”箭头时,列出的帖子将淡出,下一页帖子将加载然后淡入。
淡出效果很好,但新内容不会淡出进去后,它会突然弹出,不会褪色。它看起来不错,但它没有做我想做的事,我无法弄清楚为什么。
这是它现在在开发环境中工作的两个地方(我还没有在 FF 3.5、FF 3.6 和 Chrome 之外进行真正的跨浏览器测试,所以如果您使用 IE,它可能无法按预期工作):
http://kendraschaefer.com/mandapop/gallery/ http://kendraschaefer.com/mandapop/blog/
这是相应的 jQuery:
$(document).ready(function(){
$('#postPagination a').live('click', function(e){
$('#blogListColWrapper, #galleryListColWrapper').fadeOut(200).load(link + ' #blogListCol', function(){
$('#blogListColWrapper, #galleryListColWrapper').fadeIn(300);
Cufon.refresh(); });
});
});
我已经尝试了我能想到的一切。任何想法将不胜感激。
I'm developing a WordPress 3.0 theme, my first theme with a bit of jQuery enhancement. I'm trying to fade out and fade in the pagination on each posts area. The idea is that when a user click the "prev" or "next" arrows, the listed posts will fade out, the next page of posts will load and then fade in.
The fadeouts work fine, but the new content doesn't fade in, it just pops in with no fade. It looks OK, but it's not doing what I want and I can't sort out why.
Here are the two places it's working now on the dev environment (I haven't really cross browser tested yet outside of FF 3.5, FF 3.6 and Chrome, so if you're on IE it may not work as expected):
http://kendraschaefer.com/mandapop/gallery/
http://kendraschaefer.com/mandapop/blog/
And here's the corresponding jQuery:
$(document).ready(function(){
$('#postPagination a').live('click', function(e){
$('#blogListColWrapper, #galleryListColWrapper').fadeOut(200).load(link + ' #blogListCol', function(){
$('#blogListColWrapper, #galleryListColWrapper').fadeIn(300);
Cufon.refresh(); });
});
});
I've tried everything I can think of. Any ideas would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即时淡入是因为链接正在执行它的默认行为...加载新页面,观察您的 URL 以查看它的变化:)
我认为总的来说您正在寻找的是这样的:
这有一些变化,首先使用
e.preventDefault()
来阻止链接从实际进入页面开始。在link
未定义后,您需要从您单击的链接中提取href
属性。有几种方法可以处理的
你正在做的事情,我只是做了一个简单的#id
部分.load().each()
此处,其中this
指的是实际加载的 div,因此您可以获取id
属性。这是一种没有each的替代方法,但如果两者
#blogLostColWrapper
和#galleryListColWrapper
都在页面中,它会更容易崩溃......希望情况并非如此:The instant fade-in is because the link is doing it's default behavior...loading a new page, watch your URL to see it change :)
I think overall what you're looking for is something like this:
This has a few changes, first the
e.preventDefault()
to prevent the link from actually going to the page. After thatlink
was undefined, you need to pull thehref
attribute from the link you're clicking. There are a couple of ways to go about the#id
part of the.load()
you're doing, I just did a simple.each()
here, wherethis
refers to the div that's actually loading so you can grab theid
property.Here's an alternative way without the each, but it'll break more easily if both
#blogLostColWrapper
and#galleryListColWrapper
are in the page...hopefully that's not the case: