iScroll Reset function
I am using iScroll to ensure compatibility of our admin area. The documentation lists what to do if you load in a page via ajax to reset the scroll area but I cannot get it to work.
documentation is here : http://cubiq.org/iscroll-4 just over a third of the way down 'mastering the开发者_Go百科 refresh'
The documents uses myscroll as a variable. I have implemented something similar and it is working as it works out where the content is but does not reset the scroller thus one cannot see content loaded in via ajax that is larger than the initial.
Can anyone work it out.
Many Thanks,
You say that this is not working?
setTimeout(function () {
myScroll.refresh();
}, 0);
Are you using jQuery .load or .ajax to load the new content?
For ajax, put as option, dataType: 'html' to ensure it will run any script inside tag that will come with the data you loaded.
Then, put at the end of your loaded document:
<script type="text/javascript">
$(document).ready(function() {
setTimeout(function() {
myScroll.refresh();
}, 0);
});
</script>
(considering you are using jQuery).
Remember that myScroll and myscroll are two different things since its case-sensitive. Re-check your myscroll name.
Anyways, that works for me.
This might be too late, but I've found the solution by myself. The refresh() function will not reset the zoom scale, so we have to change the zoom scale manually by following function call
.zoom(X, Y, scale);
example :
.zoom(0,0,1); this will reset the zoom scale to 1 (maximum zoom out or no zoom)
This might help other people that having the same problem in iscroll 4.
精彩评论