I remember this worked for me:
var scrollName = new Array();
var scrollId = new Array();
$('.myclass').each(function(index) {
scrollId[index] = $(this).attr('id');
setTimeout(function() {
scrollName[index] = new IScroll(scrollId[index], {
mouseWheel: true,
scrollbars: true,
interactiveScrollbars: true
scrollbars: 'custom'
});
}, 100);
});
It worked with iScroll 4, but I think no problem with version 5.
———————————————————————————————————————
UPDATE 1
Multiple iScrolls by class
In iScroll 5 you can use a class as selector:
var scroller = new Array();
$('.myclass').each(function(){
myScroller = new IScroll(this, {
scrollX: false,
scrollY: true,
mouseWheel: true,
scrollbars: true,
interactiveScrollbars: true
});
scroller.push(myScroller);
});
The different scrollers can be triggered with:
scroller[0].scrollTo(0, -100, 500);
scroller[1].scrollTo(0, -200, 500);
So you don't need to specify an id. As long as you don't want different options.
———————————————————————————————————————
UPDATE 2
Multiple iScrolls by id
Here is a working example by using multiple id selectors
var scroller = new Array();
var selfId = new Array();
$('.myclass').each(function(){
selfId = $(this).attr('id');
myScroller = new IScroll('#' + selfId, {
scrollX: false,
scrollY: true,
mouseWheel: true,
scrollbars: true,
interactiveScrollbars: true
});
scroller.push(myScroller);
console.log(selfId.toString());
});
The different scrollers can be triggered with:
scroller[0].scrollTo(0, -100, 500);
scroller[1].scrollTo(0, -200, 500);