I’m not sure I worded my question correctly but anyhow…
I’m using iscroll and wrapped the iScroll init call in a private function for my use later. this is what I have:
Namespace.iscroll = function () {
var myScroll;
myScroll = new iScroll('mainContent-wrap', {
hScrollbar: false
});
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', Namespace.iscroll, false);
};
I call iscroll on any page I need by using Namespace.iscroll();
My question is, now I want to refresh iScroll using myScroll.refresh();, or using the setTimeout function as descriobed in the iScroll documentation.
Since I wrapped the original init call in a private function how to I run the refresh, and other methods (like destroy) on it?
If you’re trying to get access to the
myScrollvariable after theiscrollfunction has been run, the answer is you can’t. It’s gone at that point. You will have to save it somewhere else so you can get to it. One idea is to put it on the same object asiscrolllike this:You can then do a refesh like this:
The key is that you store myScroll in some persistent and public location that isn’t a temporary local variable.