Solved

scrollable page navigation

Posted on 2012-03-26
9
337 Views
Last Modified: 2012-03-28
The following is a link to a page containing a jquery scroller http://gromit.utopia.co.nz/~thebette/play/slider.html.
The code was taken from this website http://musca.se/full-window-width-jquery-tools-content-slider-demo/.

I am trying to modify the script to allow me to change the default first screen. At the moment the page opens on slide 1. What I need to be able to open the page on an alternate slide (so I can navigate direct to a particular item from an alternate page).
Assistance appreciated.
Cheers,
N
0
Comment
Question by:Neil_Bradley
  • 5
  • 2
  • 2
9 Comments
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 250 total points
ID: 37771358
This code wil scroll to the slide number given as

#1
#2
#3
after the url

$(document).ready(function() {
  var page = parseInt(location.hash.substring(1),10); 
  if (isNaN(page)) page=1;
  $("#navigation li:nth-child(page)").trigger("click");
});

Open in new window

0
 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 250 total points
ID: 37772887
you can try the code below

$(function() {
         var defaultPageNumber =1
         var ctlPager = $("#navigation li").removeClass("active");
         $.each(ctlPager,function(i,j) {
             if((i+1) == defaultPageNumber )
            {  
                  $(this).addClass("active").click(); return false;
             }
        });
});

Just change the value of defaultPageNumber  to set the default page you want;

Hope this will solve your issue.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37773473
no need to add or remove active, just click the li
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:Neil_Bradley
ID: 37773625
Reply to mplungjan.
I have implemented your code. A link to your slider test page can be found here: http://gromit.utopia.co.nz/~thebette/play/linkTo.html
As you will see, no matter which link I click on the slider page opens, then scrolls to the last item. Can you have a look and see if there is anything wrong with the way I have implemented you code?

Reply to Lalit-Chandra
You code works perfectly (here is the working page http://gromit.utopia.co.nz/~thebette/play/solution2.html).  If I wanted to modify your code so that:
1. The default page is set by the number after the # in the url. IE clicking to slider.html#2 from another page takes me directly to that item as opposed to slider.html#2 opening then scrolling.

To summarize. if I am on the slider page then the navigation should move the slider. If I click a link to the slider page (IE slider.html#2)  then the item clicked on should show by default as opposed to the page opening then the slider sliding to the item.
Thanks for your input.
N
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37774976
I'll look in a few hours
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37775107
I do not see my code at all at the link you gave
0
 
LVL 7

Expert Comment

by:Lalit Chandra
ID: 37775299
hi  Neil_Bradley,

As your this post question

Scroll Page Navigation
I am trying to modify the script to allow me to change the default first screen. At the moment the page opens on slide 1.

has been solved.So,please close this post,as now your question is now moving in another direction and you want the solution.
So, Please close the post and start a new post of this, as there is only one question per post.

Hope you understand.

Thanks
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37775339
Lalit-Chandra - there is nothing new in the post by Neil.

the code I posted will do exactly what has been asked.
If you change

http://gromit.utopia.co.nz/~thebette/play/slider.html

from

// Scrollable and navigator plugin settings.
$("#slider").scrollable({ easing: 'easeOutQuad', speed: 900, circular: true }).navigator({ navi: '#navigation' });

Open in new window


to

// Scrollable and navigator plugin settings.
$("#slider").scrollable({ easing: 'easeOutQuad', speed: 900, circular: true }).navigator({ navi: '#navigation' });

var page = parseInt(location.hash.substring(1),10); 
if (isNaN(page)) page=1;
$("#navigation li:nth-child(page)").trigger("click");

Open in new window


it should works as expected with a link to

http://gromit.utopia.co.nz/~thebette/play/slider.html#1
http://gromit.utopia.co.nz/~thebette/play/slider.html#2
http://gromit.utopia.co.nz/~thebette/play/slider.html#3

going to slide 1, 2 and 3
0
 
LVL 5

Author Closing Comment

by:Neil_Bradley
ID: 37778743
Thank you to both mplungjan and Lalit-Chandra for your submissions. The final solution came from combining both suggestions. I realize that that my question was quite complex so I am sure that I will soon be posting soon with a spin of question.
Thanks again.
Cheers,
N

Final solution:
 var page = parseInt(location.hash.substring(1),10);  
   var ctlPager = $("#navigation li");
         $.each(ctlPager,function(i,j) {
             if((i+1) == page )
            {  
                  $(this).addClass("active").click(); return false;
             }
        });
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Permission on folders 6 23
[form-control] Retain values after a POST action 21 33
modify change color of text 9 36
Check input text, Number 6 31
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question