Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

scrollable page navigation

Posted on 2012-03-26
9
Medium Priority
?
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

 
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

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

660 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