views:

82

answers:

2

Hello,

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("#");
$('.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!

+1  A: 

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.

weesilmania
A: 

Mike, I'm trying to do the same thing and was wondering if you were able to get this to work? I edited the pajinate plugin code to add the #page_num to the URL of the page (your code worked beautifully), but still haven't figured out what code to use to have each #page load a specific page.

Many thanks!

designgirl