使用 iscroll 与 jquery 移动绑定问题
我目前正在绞尽脑汁地尝试让 iscroll 4 与 jQuery Mobile 一起使用。
如果我禁用 JQM ajax 默认导航,一切都会正常工作,但我想保留它。
我的问题是我无法弄清楚如何成功调用/绑定 iscroll,以便它适用于需要它们的页面。我尝试过 pageinit() 和 pagecreate() 无济于事。
可以在这里找到这方面的基本示例: http://bit.ly/ngXkNR
非常感谢任何指点。
一个。
Im currently pulling my hair out trying to get iscroll 4 working with jQuery Mobile.
It all works fine if i disable JQM ajax default navigation but I would like to retain this.
My issue is I cant work out how to successfully call/bind iscroll so it works with the pages that need them. I have tried pageinit() and pagecreate() to no avail.
A basic example of this can be found here:
http://bit.ly/ngXkNR
Any pointers much appreciated.
A.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
谢谢贾斯珀,
我稍微改变了你的方法,这样你就可以在用类标识的任何包装器上调用 iScroll 。
另外,我卸载并销毁 pagehide 事件上的所有 iScroll 实例 - 我不需要刷新方法来满足我的需要:
Thanks Jasper,
I changed your method a bit, so that you can call iScroll on any wrapper identified with a class.
Also I unload and destroy all iScroll instances on the pagehide event - i dont need the refresh method for my needs:
按照我四天前为您创建的示例(将 iscroll 与 jquery mobile 结合使用 )... 您要绑定到仅在初始页面加载时触发的事件,并且希望绑定到每当新页面添加到 DOM 时触发的 jQuery Mobile 事件。
更改:
至:
这将需要将每个页面上的
wrapper
div 重命名为 _wrapper。无论如何,这是必要的,因为每个具有 ID 的元素在 DOM 中都需要一个唯一的 ID。链接:将 iscroll 与 jquery mobile 结合使用
--UPDATE- -
我创建了一个在多个页面上使用 iScroll 轮播的示例。请注意我如何在每个页面上包含自定义 JavaScript 和 CSS,这样如果用户刷新页面(在任何页面上),他们就不会因为缺少代码而收到任何错误。
以下是工作示例的链接: http://apexeleven.com/stackoverflow/iScroll/default .html
Follow the example I created for you four days ago ( using iscroll with jquery mobile )... You are binding to an event that only fires on the initial page load and you want to bind to a jQuery Mobile event that fires whenever a new page is added to the DOM.
Change:
To:
Which will require renaming the
wrapper
div on each page to _wrapper. Which is necessary anyway because each element with an ID needs a unique ID in the DOM.Link: using iscroll with jquery mobile
--UPDATE--
I have created an example of using iScroll carousels on multiple pages. Notice how I include the custom JavaScript and CSS on each page so if the user refreshes the page (on any page) they will not receive any errors because of missing code.
Here is the link to the working example: http://apexeleven.com/stackoverflow/iScroll/default.html