Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

scrollable page navigation

Posted on 2012-03-26
9
Medium Priority
?
343 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 1000 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 1000 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
Technology Partners: 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

916 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