【发布时间】:2012-07-31 23:17:45
【问题描述】:
这将是一个很长的帖子,但我真的受够了试图解决这个问题。我真的在寻求一些帮助来解决我的问题。
第一:
fade.js:
$(document).ready(function(){
$(".gallery ul li img.a").fadeTo("slow", 0.5); // This sets the opacity of the thumbs to fade down to 30% when the page loads
$(".gallery ul li img.a").hover(function(){
$(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
},function(){
$(this).fadeTo("slow", 0.5); // This should set the opacity back to 30% on mouseout
});
});
这里的问题是在下一页的ajax调用之后,淡入淡出停止工作。所以我做的是
$(document).ready(function(){
$(".gallery ul li img.a").fadeTo("slow", 0.5); // This sets the opacity of the thumbs to fade down to 30% when the page loads
$(".gallery ul li img.a").live("hover", function(){
$(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
},function(){
$(this).fadeTo("slow", 0.5); // This should set the opacity back to 30% on mouseout
});
});
但这只有在我将鼠标悬停在图像上时才会起作用,然后图像就会淡出。如果我对$(".gallery ul li img.a").fadeTo 到.live(...) 执行相同操作,则没有任何反应,它根本行不通。
- 即使在 ajax 调用之后,它应该如何在加载时淡出,然后当我将鼠标悬停在它上面时淡出。
第二:
我有一个小滑块,可以在图像上向上滑动,slider.js:
$(document).ready(function(){
//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
//Full Caption Sliding (Hidden to Visible)
$('.gallery li').hover(function(){
$(".cover", this).stop().animate({top:'106px'},{queue:false,duration:160});
}, function() {
$(".cover", this).stop().animate({top:'153px'},{queue:false,duration:160});
});
});
我将$('.gallery li').hover(...) 更改为$('.gallery li').live("hover", function(){...}),但还是不行。我还使用了.on 而不是.live,因为它已被弃用。
我做错了什么?我不是客户端的家伙,我的大部分工作都是服务器端的。我只需要在 AJAX 调用发生后让这 2 个插件工作。
阿贾克斯:
@dajaxice_register
def gallerypages(request, p):
try:
page = int(p)
except:
page = 1
items = gallerylist(page)
html = render_to_string('gallery_content.html',
{'items': items,},
context_instance = RequestContext(request))
dajax = Dajax()
dajax.assign('#gallery-content', 'innerHTML', html)
return dajax.json()
编辑2:
<a href="#" onclick="Dajaxice.gallery.gallerypages(Dajax.process, {'p': {{ items.previous_page_number }},})" class="btn_prev"><b><</b></a>
和
$(document).on("keydown", "#pagenumber", function(e)
if ( e.which === 13 ) {
Dajaxice.gallery.gallerypages(Dajax.process, {'p': this.value});
}});
【问题讨论】:
-
Ajax 调用到底在做什么?
-
对不起,我没有提到这一点,Ajax 调用只会在图库中加载下一页,我有一个 div 中的图像列表。
-
在ajax调用完成后重新运行fade.js。
-
ajax调用完成后如何重新运行?只是指出我使用的是 Dajax 而不是 Ajax,它是 Django 的 Ajax。它有点不同,没有成功或什么。如果我可以在通话后运行一个函数,我现在会检查一下。
-
我希望它有一个活动:)
标签: javascript jquery django dajaxice dajax