jCarousel 重置滚动位置
我有一个关于在 jCarousel 中加载新数据时重置滚动位置的问题。 链接在这里: http://rjwcollective.com/equinox/rishi_gallery/eqgall.php
新数据进来当您单击左侧边栏中的过滤器时。 但是,如果您开始在右侧边栏的轮播中滚动,然后重新选择过滤器,则新加载的数据不会重置到顶部位置。
我使用 .empty() 清空 div 中的数据
场景如下:
第一次加载:
//first load
$.ajax({
type:"POST",
url:"sortbystate.php",
data:"city=&gender=&category=",
success:function(data){
//carousel
$('#thumbs').html(data);
}
});//end ajax
过滤器选择:
$(".statelist :input").click(function(){
$('#thumbs').empty();
var state = $('.statelist input:checked').attr('value');
var gender = $('.gender input:checked').attr('value');
var category =$('.category input:checked').attr('value');
$.ajax({
type:"POST",
url:"sortbystate.php",
data:"city="+state+"&gender="+gender+"&category="+category,
success:function(data){
$('#thumbs').html(data);
}
});//end ajax
});
I have a question about resetting the scroll position when I load new data in the jCarousel.
The link is here:
http://rjwcollective.com/equinox/rishi_gallery/eqgall.php
New data comes in when you click on the filters in the sidebar on the left.
However, if you start scrolling in the carousel on the right sidebar and then reselect filters, the newly loaded data doesn't reset to the top position.
I am emptying out the data in the div using .empty()
The scenario is like this:
First Load:
//first load
$.ajax({
type:"POST",
url:"sortbystate.php",
data:"city=&gender=&category=",
success:function(data){
//carousel
$('#thumbs').html(data);
}
});//end ajax
Filter selection:
$(".statelist :input").click(function(){
$('#thumbs').empty();
var state = $('.statelist input:checked').attr('value');
var gender = $('.gender input:checked').attr('value');
var category =$('.category input:checked').attr('value');
$.ajax({
type:"POST",
url:"sortbystate.php",
data:"city="+state+"&gender="+gender+"&category="+category,
success:function(data){
$('#thumbs').html(data);
}
});//end ajax
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在加载新数据时重置轮播:
这将清除并重置位置。
或者你可以直接调用 carousel.pos(0);回到起点。
如果您需要更多功能,最好查看源中提供的功能:
https://github.com/jsor/jcarousel/blob/master/lib/jquery.jcarousel.js
You can either reset the carousel as the new data is loaded:
this will clear and reset the position.
Or you can just call carousel.pos(0); to move back to the start.
If you need more function it is best to look at the function available in the source:
https://github.com/jsor/jcarousel/blob/master/lib/jquery.jcarousel.js
我不熟悉 jcarousel,但看起来它的行为很奇怪,因为您需要在 carousel 对象上
.add
。相反,您只需设置 HTML。看看这里的 ajax 示例(动态示例):http://sorgalla.com/ jcarousel/
I'm unfamiliar with jcarousel but it looks like it's acting weird because you need to
.add
on the carousel object. Instead your just setting the HTML.Take a look at the ajax samples here (dynamic examples): http://sorgalla.com/jcarousel/