Cómo pasar el índice actual a fancybox iframe

I have a group of links that I call fancybox on with the arrows enabled so that the user can click next and prev. Each link is decorated with the iframe class and href='/editdata.aspx'. I would to remove the arrows and pass in the current index so that the editdata.aspx save button can say "save and next" until it reaches the last link, which will then say "save and close".

From editdata.aspx I use

var numLinks = $(".link-items", parent.document.body).children("a.iframe").size();

This gives me the total number of links. I just need to know the current link that is being displayed to the user so that I can update the save button text.

Here is a sample of my code in editdata.aspx:

// change the save button to save and next if fancybox is loading multiple links
        if (parent.$.fancybox) {
            var links = $(".links", parent.document.body);
            if (links && links.length > 0) {
                var numlinks  = $(links).children("a.popup").size();
                var index = getParameterByName('index');
                if (index == numlinks ) {
                    // this element is the last item to display so change the "save and next" to "save and close"
                    $("#btnSave").val("Save & Close");
                    $("#btnSave").click(function () {
                else {
                    $("#btnSave").val("Save & Next");
                    $("#btnSave").click(function () {

function getParameterByName(name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regexS = "[\\?&]" + name + "=([^&#]*)";
        var regex = new RegExp(regexS);
        var results = regex.exec(window.location.href);
        if (results == null)
            return "";
            return decodeURIComponent(results[1].replace(/\+/g, " "));

¿Cómo puedo conseguir esto?

preguntado el 12 de junio de 12 a las 22:06

1 Respuestas

Thats easy for v2 -

    beforeLoad : function() {
        this.href = this.href + '?index=' + this.index;

Respondido el 13 de junio de 12 a las 16:06

This doesn't seem to work for me. The value for this.index is always the same number. All the href's have the same index value. - Chelín

I updated my question to include the jquery I am using in my iframe page. - Chelín

That is definitely working for me. btw, you can get index within iframe like - parent.$.fancybox.current.index - Janis

(or use parent.$.fancybox.coming.index if you are preloading the iframe) - Janis

Yes you are correct. There is something else in my code that is causing issues. When I create a simple test page the index is loading correctly. - Chelín

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.