- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在backbone.js应用程序中使用iScroll4。我有几个动态加载的列表,我想在加载适当的 View 后初始化 iScroll。
当 ListView 加载完成时,我尝试调用“new iScroll”,但我无法弄清楚如何执行此操作。
有人让这两个一起工作吗?是否有一个主干 View 在其元素加载后初始化滚动条的示例?
最佳答案
你是对的,你必须先加载 View ,或者随后刷新 iscroll
在我们的应用中,我们通常使用render方法来渲染 View 并有一个 postRender 方法来处理这些额外插件的初始化,例如 iscroll
当然,您需要一些手动工作来完成它,但这就是它的要点:
var myView = Backbone.View.extend({
// more functions go here, like initialize and stuff... but I left them out because only render & postRender are important for this topic
// lets say we have a render method like this:
render: function() {
var data = this.collection.toJSON();
this.$el.html(Handlebars.templates['spotlightCarousel.tmpl'](data));
return this;
},
// we added the postRender ourself:
postRender: function() {
var noOfSlides = this.collection.size();
$('#carouselscroller').width(noOfSlides * 320);
this.scroller = new IScroll('carouselwrapper', {
snap: true,
momentum: false,
hScrollbar: false
});
}
});
现在调用这些方法我们在我们的 View 之外执行此操作,因为我们喜欢一些 View 管理器来处理此问题但归结起来就是这样
var col = new myCollection();
var view = new myView({ collection: col });
$('#wrapper').html(view.render().$el); // this chaining is only possible due to the render function returning the whole view again.
// here we always test if the view has a postRender function... if so, we call it
if (view.postRender) {
view.postRender();
}
关于backbone.js - 无法让 iscroll4 与主干 View 一起播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9674665/
我有 2 个列表,我使用 iScroll 进行垂直滚动。 第二个列表在第一个列表中。 当我滚动第二个列表时,第一个列表也在滚动。 我希望当我滚动内部列表(第二个列表)时,主列表(第一个列表)不会滚动。
我在垂直内实现 Carousel 时遇到了问题我滚动。由于 Carousel 是水平滚动的,而 iScroll 是垂直滚动,它会导致故障,因为 Carousel 滚动垂直,即使我禁用它。 我尝试将两个
我有一个带有 IScroll 的 div 在另一个带有 IScroll 的 div 中。每当我尝试在子 div 上滚动时,父级也会滚动,所以这是一种糟糕的用户体验。 我不想获取每个变量并告诉它暂时禁用
我在 android phonegap 中创建了应用程序。我使用 iscoll 在 div 中动态显示滚动条,因为我附加了列表并动态显示。 它显示带有附加列表的div,但不显示滚动条。 在 logca
我创建了一个页面,该页面对页眉和页脚使用固定定位,并且还必须在 iPad/iPhone 上工作。我正在使用 iScroll.js (http://cubiq.org/iscroll-4) 在 iPad
我已经阅读了很多关于此的论坛,但没有一个解决了我的问题。我确定它是我遗漏的小东西 这是 iscroll 初始化: // make PI scroll piScroll2 = new iScroll('
我有一个带有交互式滚动条的水平 iScroll 实例。 myScroll = new IScroll('#wrapper', { scrollX: true,
我正在尝试使用 IScroll 库中的scrollToElement 函数,但无法让它工作。 new IScroll(document.querySelector(".wrapper")).scrol
我正在尝试使用 iscroll 插件 ( https://github.com/cubiq/iscroll ) 为 div 添加滚动功能。我发现它使滚动父项内的链接不可单击。禁用该插件可以修复它。 起
我正在 iOS 和 Android 上的 Phonegap 上开发一个演示,我选择 iScroll 来使页面可滚动,它工作正常,但我必须在创建 DOM 元素后生成 iScroll,因此 iScroll
有谁知道怎么做iScroll像旋转木马一样,有没有办法制作 iScroll自动在“ul”内循环? 因为我想在 iOS 上使用它,所以我一直在想办法.. 非常感谢您抽出时间。 最佳答案 以下内容应该有效
iPad 上 Mobile Safari 中的 HTML5 模板。带 iScroll 的 Div 工作正常。 if/else 语句中还包含一个 jQuery 函数。该函数测试用户是否在 iScroll
如果您输入http://gizeto.se/app_yellow/index.html你可以看到 iScroll 滚动整个页面。您可以看到滚动条位于页眉和页脚上方。滚动条应该只滚动内容,不包括页眉和页
我有一个 iOS 网络应用程序,它被证明在滚动方面非常困难! iScroll 4 终于解决了这个问题。但是,当我将手指从屏幕上移开时,滚动部分似乎又回到了原来的位置。 有人知道为什么会这样以及如何解决
我是这样调用它的 document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); docume
我试图了解视差如何与 iscroll5 配合使用。据我了解,我可以将容器定义为改变滚动速度的指示器。然而我需要做的是同时对多个元素应用速度比。 让我们以下面的示例为例,如何立即更改所有 h2 元素的
如何防止 iScroll 移出页面? https://github.com/cubiq/iscroll/blob/master/demos/simple/index.html 即。这个: 向上滚动时变
我想在 ipad 中滚动 div。我用的是滚动。像这样: $(document).on("pagecreate",function(event){ var myScroll = new IS
iScroll 文档显示了典型的 iScroll 设置,如下所示。 var myScroll; function loaded() { setTimeout(function () {
我想知道是否可以使用 IScroll,更具体地说是 Angular 版本 (github.com/mtr/angular-iscroll),即使内容没有溢出?因此,可以拖动一个非溢出列表(见下图)并用
我是一名优秀的程序员,十分优秀!