I want to store the current page number in a jquery variable, but I am not sure if it is possible, so I am storing it in an input field. Am I doing it the most efficient way?
<input type='hidden' id='current_page' />
$('#current_page').val(0);
if page is changed,
function (newpage){
$('#current_page').val(page_num);
}
You can use
jQuery.data()for this -as mentioned by Nikita.But if you’d like to support the JavaScript-disabled clients as well, then I’d stick to a hidden input element. This way you can still control the pagination from the server side on. The hidden input value can then be used to inform the server side what page the client is currently sitting in.