jquery history plugin set current page possible?
I use jquery pagination plugin, unfortunately it doesn't have method to set current page from outside the object开发者_开发百科. I've really looked into this object (the function is not long), but as a jquery beginner I can not even find how the event binds (by click obviously). I have no idea how to modify this function so I can call something like: current_page(10) to set current page to 10. I have everything else working for history (using the change hash event), back now loads previous page OK, but visually the paginator doesn't move or change active page of course. I really need a trigget to make this happen.
I would be very happy if someone at least points me to the part of the function where I can modify this...
The pagination plugin actually does have this built-in, it's just in an unconventional and not-obvious way, the key is this bit:
var panel = jQuery(this);
// Attach control functions to the DOM element
this.selectPage = function(page_id){ pageSelected(page_id);}
This creates a .selectPage()
method on the DOM element the pagination links are in, for example in their demo page you'd call it like this:
$("#Pagination")[0].selectPage(9); //0-based, 9 = page 10
You can give it a try here, the setup is just replicating the demo page, but literally all I've added is the .selectPage()
call above. In the interest of full disclose there's also .prevPage()
and .nextPage()
functions available in the same way, e.g. $("#Pagination")[0].nextPage();
精彩评论