[cycle] Permalink to slide with custom hash value
At the moment I have it working with slide IDs, this is my code
- var index = 0, hash = window.location.hash;
- if (hash) {
- index = /\d+/.exec(hash)[0];
- index = (parseInt(index) || 1) - 1;
- }
- var $container = $('#content').cycle(
- {
- fx: 'scrollLeft',
- startingSlide: index,
- speed: 500,
- timeout: 0,
- pager: '#nav',
- pagerAnchorBuilder: function(idx, slide) {
- return 'nav li:eq(' + idx + ') a';
- },
- after: function(curr,next,opts) {
- window.location.hash = "!/" + (opts.currSlide + 1);
- }
- });
This generates links using the slide ID. It works well, but I think it looks messy.
Instead, I would like to to use a custom value from my navigation's href-attribute.
- <a href="#!/who-we-are">Who we are</a>
which would link to
How can I achieve this?