here is an example:
<div class="getIDX" onclick="alert($(‘#myScroll’).get(0).idx);">getIDX</div>
Supposed that your scrollable component ID is “myScroll”:
clicking on the getIDX label should return the actual index page.
You can make your own function that store the actual page index before calling the gotToPage function and than call again the goToPage() passing the stored idx as param:
$.fn.storeAndGo=function (pageNumber){
$(this).get(0).actIDX= $(this).get(0).idx;
$(this).goToPage(pageNumber);
}
Now you can make your own calls to this methods:
<div class="button" onclick="$('#myScroll').storeAndGo(5);">get IDX and go</div>
<div class="button" onclick="$('#myScroll').goToPage($('#myScroll').get(0).actIDX);">back to previous page</div>
If you want to store actual page-index in a cookie to get it once you come back to the page:
here there are three methods do manage cookies:
mb_setCookie = function(name,value,days) {
if (!days) days=7;
var date = new Date(), expires;
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
document.cookie = name+"="+value+expires+"; path=/";
};
mb_getCookie = function(name) {
var nameEQ = name+ "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
};
mb_removeCookie = function(name) {
mb_setCookie(name,"",-1);
};
You can store the value in a cookie and get it once you are back in the page:
mb_setCookie('mbScrollableIDX', $('#myScroll').get(0).idx);
When you enter the page:
var mbScrollableStoredIDX= mb_getCookie('mbScrollableIDX');
if (typeOf mbScrollableStoredIDX != 'undefined')
$('#myScroll').goToPage(mbScrollableStoredIDX);
answered
Feb 22 at 18:47
Matteo Bicocchi ♦♦
1071●1●1●7