JQuery Scrollable 动态更新后锁定
所以我一直在使用一个名为 Scrollable 的 JQuery 插件。起身和行动的轻松程度给我留下了深刻的印象,但现在我遇到了一个阻碍,希望你们能提供帮助。
我的可滚动 div 包含一堆在某个类别中“突出”的图标。如果类别发生更改,我会使用 JQuery 清除“特色项目”div,计算项目数量,并根据需要填写。我清除了所有内容,因为在有 0 的情况下,我不会向 div 写入任何内容,并且页面上的内容会进行调整。
我的问题是,清除其中之一后,滚动停止工作。我尝试
$("#scroller").scrollable({
circular: false
});
在每次更新后打电话,但这似乎并不能解决问题。我熟悉其他使用“刷新”类型命令重新加载内容的 JQuery 工具。这个插件有类似的东西吗?关于我应该做什么有什么想法吗?
谢谢!
So I've been playing around with a JQuery plugin called Scrollable. I'm impressed with how easy it was to get up and going, but now I've run into a show stopper and hope you guys can help.
My scrollable div contains a bunch of icons that are "featured" in a certain category. If the category is changed, I use JQuery to clear out the "featured items" div, calculate the number of items, and fill it in as necessary. I clear everything out because in the case there is 0 I don't write anything to the div and the content on my page adjusts.
My problem has been that after one of these clear out the scrolling stops working. I've tried calling
$("#scroller").scrollable({
circular: false
});
after every update but that doesn't seem to fix the issue. I'm familiar with other JQuery tools using a "refresh" type command that reloads the content. Is there something similar with this plugin? Any ideas on what I should be doing instead?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Scrollable 上有一个函数,
Scrollable.addItem
,它应该允许您动态添加项目。There is a function on Scrollable,
Scrollable.addItem
which should allow you to dynamically add items.我最终重写了页面,以永远不会从 DOM 中删除可伸缩的 div。这样,我最终使用了这个工作流程...
滚动到第一项。如果用户位于第 5 页,而他们选择的内容只有 3 页,那么如果您不向后滚动,用户就会陷入空白页面。
window.api.seekTo(0, 0);
清空“items”div。
$(".items").empty();
使用“addItem”方法将我的项目添加回来。
window.api.addItem(htmlToAdd);
这似乎效果更好。
I ended up rewriting the page to never remove the scollable div from the DOM. With that, I ended up using this workflow...
Scroll to the first item. If the user was on page 5 and what they select only has 3 pages, the user is stranded on a blank page if you don't scroll back.
window.api.seekTo(0, 0);
Empty the "items" div.
$(".items").empty();
Use the "addItem" method to add my items back in.
window.api.addItem(htmlToAdd);
That seemed to work much better.