Cruising2hell
Cruising2hell

Reputation: 133

Linking jQuery Cycle Pager element

I am using jQuery Cycle plugin with pagers. I need to have navigation functionality, where I can provide a link to my client and he can browse that page which is a projects gallery. I need the cycle plugin to show a particular slide. Maybe variables can be supplied in the URL to go to a specific slide. I do not mind writing another jquery script to achieve it.

In that case, I would need to get a variable on pageload from the URL (a number 'n') and make a click on a nth element inside a div.

Upvotes: 0

Views: 709

Answers (1)

seth
seth

Reputation: 37267

You could use the following to get the parameter from the query string:

 function $_GET(q,s) {
   s = (s) ? s : window.location.search; 
   var re = new RegExp('&'+q+'=([^&]*)','i');
   return (s=s.replace(/^\?/,'&').match(re)) ?s=s[1] :s='';
 }

Then in the cycle declaration you can use startingSlide (assuming the number was in the parameter param_num:

 $.cycle({
     startingSlide: $_GET('param_num'),
     // rest of your cycle config
 });

One thing to note that startingSlide is zero-based index, so the number you pass in the parameter should reflect that.

Upvotes: 2

Related Questions