Another Shadowbox.open issue

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Another Shadowbox.open issue

GaryREM
This post was updated on .
I am trying to open one of the gallery items on a page.

Using a link like
http://www.amylinart.com/Kinetics/Kinetics2_port.htm?the_item=2
(updated link to point to real site).

Snippet of code to try and do this is

var which_image = gup('the_item');
if (which_image != "") {
        var the_img = $('tr.galleryhomeMid td a').get(which_image-1);
        Shadowbox.open ({content:the_img,gallery:"gallery"})
};

This shows error "TypeError: Result of expression 'aa' [undefined] is not an object."

Commenting out Shadowbox.open on the page, refreshing the page, and running

Shadowbox.open ({content:the_img,gallery:"gallery"})

causes exactly what I want to happen, but the method returns 'undefined'.

Note Shadowbox.init has been run previously on the page. What am I missing?

Gary
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Another Shadowbox.open issue

mjijackson
Administrator
If you're going to pass your own object to Shadowbox.open, the value of the "content" parameter should be a string, not an element. See the docs.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Another Shadowbox.open issue

GaryREM
Thanks.

But passing a string seems to make no difference.

var which_image = gup('the_item');
if (which_image != "") {
        var the_img = ($('tr.galleryhomeMid td a').get(which_image-1)).toString();
        //var the_img = the_img+"";
        var options = {
                counterType:"default"
        };
        Shadowbox.open ({
                                        content:the_img,
                                        gallery:"gallery",
                                        options: options
                                        });
};

Still getting the same error (in the find function). Sample updated.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Another Shadowbox.open issue

mjijackson
Administrator
Don't try and convert the element to a string. Pass in a URL or some HTML.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Another Shadowbox.open issue

GaryREM
It would really be useful to understand what the content options are for Shadowbox.open.

var the_img = ($('tr.galleryhomeMid td a').get(which_image-1)).toString(); does generate a string (typeof the_img is a string); the value is similar to the following:

'http://192.168.1.199/works/AmyLinAttachment.jpg'

But setting content: the_img        or
setting content:'http://192.168.1.199/works/AmyLinAttachment.jpg'

still results in the error.

Running the shadowbox open function in the browser console pops up the right content from the gallery and even puts in the title and correct item number, but it returns undefined. But, I have to comment out the function on the page, because, once run, the page is broken.

(Also, an item I was testing  had a space in the title name that had to be encoded.)

Very frustrating.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Another Shadowbox.open issue

GaryREM
The problem specifically appears to be in the onOpen method. the container is not defined and the error is occurring when the

aa.style.display="block";

line is being executed.

Do you have any examples where Shadowbox.open is being used to show an image so I can see it working?

Thanks.

Gary
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Another Shadowbox.open issue - problem solved

GaryREM
OK.

The issue here was that I was trying to read a URL parameter and call Shadowbox open BEFORE it had initialized.

So, expanded the script where the Shadowbox.init() was to register events.

Shadowbox.init({
        //skipSetup: true
        handleOversize: "resize",
        overlayOpacity: 0.9
});
if (window.addEventListener)
{
  window.addEventListener('load', updatenav_new, false);
  window.addEventListener('load', doit, false);
}
else if (window.attachEvent)
{
  window.attachEvent('onload', updatenav_new);
  window.attachEvent('onload', doit);
}

Now I can send someone a link to a given item and it will open to that image in Shadowbox.

E.g. http://www.amylinart.com/Kinetics/Kinetics2_port.htm?the_item=6

The code for opening the right image is:

function doit(){
        var which_image = Number(gup('the_item'));
        if (which_image != "") {
                var options = {
                        counterType:"default"
                };
                var content = Shadowbox.cache[which_image].content;
                Shadowbox.open ({
                                        content: content,
                                        player: "img",
                                        gallery: "gallery",
                                        options: options
                                        });
        };
}

Now I'm happy.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Another Shadowbox.open issue

Infario
In reply to this post by GaryREM
i made this working finally by reffering so may forums. I am posting here may be helpful for other people searching this

add this on the first iframe page

  function openSB(path,width,height){
var Shadowbox = window.parent.Shadowbox;
Shadowbox.gallery[Shadowbox.current].content = path;
Shadowbox.gallery[Shadowbox.current].width = width;
Shadowbox.gallery[Shadowbox.current].height = height;
Shadowbox.change(Shadowbox.current);
}

then link the next iframe page like this.

<a href="javascript:openSB('popup/user/login','350','300');" >Login here

thatsit!. it will resize and load content smoothly. May you can pass 'player' parameter if you wish
Loading...