This question is specific to jquery.pajinate.js. Basically it's a pagination plugin for jQuery that works great! I'm actually trying to add in some Unique URL functionality so that after jquery.pajinate() builds my pagination links, I can link to a specific page. This seems logical especially if someone wants to share a specific page of something with someone else.
Inside of jquery.pajinate.js, there is the following code that executes when someone clicks another page link inside the "pajinated" code:
function goto(page_num) {
...
};
I've written the following custom code that will get the contents of my URL and then append "#page_num" when someone clicks a page link, producing http://website.com/category/shorts/#page2
var pageURL = window.location.href.split("开发者_如何学Go#");
$('.page_link').click(function () {
window.location.href = pageURL[0]+"#page"+$("span", this).text();
});
QUESTION
Now, I'd like to call the goto() function publicly and outside of the scope of the pajinate function. So I'll need it to look something like this:
function after_page_loads() {
if url contains "#pageX"
goto(X);
}
I don't need help writing that function, just how to call the goto() from inside that function. Right now I'm getting an error that says, "TypeError: $("#content").goto is not a function". By the way, #content is the object I'm pajinate()-ing.
THANKS!
The start_page option for the plugin determines which page to "open" on page load (or whichever event you dictate). See the paginated list title "Custom Start Page" in the demo for an example.
精彩评论