1

I implemented the manual-script from fancybox:

$("#manual2").click(function() {
    $.fancybox([
        'http://farm5.static.flickr.com/4044/4286199901_33844563eb.jpg',
        'http://farm3.static.flickr.com/2687/4220681515_cc4f42d6b9.jpg',
        {
            'href'  : 'http://farm5.static.flickr.com/4005/4213562882_851e92f326.jpg',
            'title' : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
        }
    ], {
        'padding'           : 0,
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'type'              : 'image',
        'changeFade'        : 0
    });
});

now I'm wondering, if it's possible to get directly to a specific picture by clicking on the link. (for example directly to the second other third picture).

  • ¿ (for example directly to the second other third picture). ? – Toni Michel Caubet Feb 02 '12 at 17:04
  • Wait a minute? I answered your first question, then your second question ... then JFK duplicates my answer to your second question and he gets the "best answer"? Please correct this. – Timothy Aaron Feb 02 '12 at 21:02
  • @TimothyAaron: A moderator deleted my answer. I didn't mean any harm. It took me more than 5 minutes to write my answer and didn't see your comments in the meantime. I agree you should be awarded with the "correct answer" (I even voted up yours.) I apologize for any misunderstanding here. – JFK Feb 13 '12 at 17:40
  • Just for the record: I don't need to copy the (fancybox) code or answers of anybody else. I have actually answered more fancybox questions than anybody ever has (about 3,000) ... and actually most of my examples and code have been used (or copied) as reference in different forums (including stackoverflow) so please don't see me as an opportunist or like one who plagiarizes you. See http://groups.google.com/group/fancybox/about for more. Sorry again for any inconvenience. – JFK Feb 13 '12 at 17:42
  • @JFK No problem. It's more an oversight of Marc's than yours; you were just trying to help. :) – Timothy Aaron Feb 13 '12 at 17:44

1 Answers1

3

To start on the second slide just add 'index' : 1, to your options json.

Here's it completely written out...

$("#manual2").click(function() {
    $.fancybox([
        'http://farm5.static.flickr.com/4044/4286199901_33844563eb.jpg',
        'http://farm3.static.flickr.com/2687/4220681515_cc4f42d6b9.jpg',
        {
            'href'  : 'http://farm5.static.flickr.com/4005/4213562882_851e92f326.jpg',
            'title' : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
        }
    ], {
        'index'             : 1,
        'padding'           : 0,
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'type'              : 'image',
        'changeFade'        : 0
    });
});

Must have version 1.3.1 or higher. See the Fancybox API for more details: http://fancybox.net/api

UPDATE: You asked if the index can be set from the links themselves, and the answer is yes. Just make sure you set which slide you want to open using a custom data- attribute (e.g., data-index="2"), then use this instead of the previous code ...

$("#manual2").click(function() {
    $.fancybox([
        'http://farm5.static.flickr.com/4044/4286199901_33844563eb.jpg',
        'http://farm3.static.flickr.com/2687/4220681515_cc4f42d6b9.jpg',
        {
            'href'  : 'http://farm5.static.flickr.com/4005/4213562882_851e92f326.jpg',
            'title' : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
        }
    ], {
        'index'             : $(this).data('index'),
        'padding'           : 0,
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'type'              : 'image',
        'changeFade'        : 0
    });
});
Timothy Aaron
  • 3,059
  • 19
  • 22
  • Don't forget computer arrays start at 0, so you'll have to subtract a 1 from whichever slide you want to start at. – Timothy Aaron Feb 02 '12 at 17:10
  • is ist possible to set the index within the link-tag? something like: [code]click[/code] and [code]$("#manual2").click(function( pic_index ) { ... 'index' : pic_index, ...[/code] – Marc-Alexander Iten Feb 02 '12 at 18:31
  • Sure can. In your fancybox options use `'index':$(this).data('index')` then just add a `data-index="2"`attribute to your link. _ps. in comments, use the ` character instead of [code]_ – Timothy Aaron Feb 02 '12 at 19:00
  • +1 to Timothy: index is the right option ... but then you are asking a second question. See my answer. – JFK Feb 02 '12 at 19:05
  • @Marc-AlexanderIten: Could you please reconsider the correct answer? I think Timothy here has helped you the most. Timothy, you might want to [edit] to update your answer with your comments. Comments are liable to disappear at any moment... –  Feb 13 '12 at 14:17
  • I would just add that if Marc wants to have a valid code, then he should use ` ` since `data-` attributes are valid for `HTML5` only. – JFK Feb 13 '12 at 20:46