Sunday, 15 September 2013

hyperlink - Clicking link changes url in browser bar, but doesn't actually load URL (may be AnythingSlider related) -



hyperlink - Clicking link changes url in browser bar, but doesn't actually load URL (may be AnythingSlider related) -

i'm using anythingslider. have link page , slide, this:

<a href='http://sitename.com/pagename/#panel1-1'>click me</a>

updated clarity: problem when create link this, direct link page & slide works when link isn't on page slide, doesn't work when it's on same page slide. since have these links on site, , it's dynamic, needed way able link slide, work on page - including page slide is.

i found solution - i'm linking slide before, , dynamically updating action on link pages link appears on same page slider.

** solution (the gist used site, edit suit purposes): **

//get anythingslider links, , dynamically update them jump slider $("a").each(function(){ var pathname = window.location.pathname.replace(/^https?:\/\/critter.co/,''); var link = this.href.replace(/^https?:\/\/critter.co/,''); if(link.indexof("/settings/home") == 0 && pathname.indexof("/settings/home") == 0){ $(this).removeattr("href"); slidenum = parseint(link.charat(link.length-1)); $(this).click(function(){ $("ul#slider").anythingslider(link.charat(link.length-1)); }); } if(link.indexof("/record/home") == 0 && pathname.indexof("/record/home") == 0){ $(this).removeattr("href"); slidenum = parseint(link.charat(link.length-1)); $(this).click(function(){ $("ul#slider").anythingslider(link.charat(link.length-1)); }); } })

i'm not quite sure understand you, pages beingness on right side. think issue you're having link changing url , not slides, right?

first off, pagename/ linking page, should working. if want command slider same page, you'll need #1-1 part; well, if have multiple sliders on page.

one slider (demo)

if have 1 slider, can this:

<nav> go slide: <a href="#1">one</a> | <a href="#2">two</a> | <a href="#3">three</a> | <a href="#4">four</a> | <a href="#5">five</a> </nav>

and code go create slider go particular slide:

$('nav a').click(function(){ $('#slider').anythingslider( $(this).attr('href').substring(1) ); }); multiple sliders (demo)

in html, i've added index slider in href attribute - #1-1 means slider 1, panel 1. here illustration of nav multiple sliders (more can added desired):

<nav> top slider: <a href="#1-1">one</a> | <a href="#1-2">two</a> | <a href="#1-3">three</a> | <a href="#1-4">four</a> | <a href="#1-5">five</a> <br> bottom slider: <a href="#2-1">one</a> | <a href="#2-2">two</a> | <a href="#2-3">three</a> | <a href="#2-4">four</a> | <a href="#2-5">five</a> </nav>

then code can used command sliders:

$('nav a').click(function(){ var link = $(this).attr('href').match(/(\d+)-(\d+)/), slider = parseint( link[1], 10 ) - 1; // eq needs 0 based index $('.slider').eq( slider ).anythingslider( link[2] ); });

hyperlink href anythingslider

No comments:

Post a Comment