Mateo
Mateo

Reputation: 79

Problem with two scripts interfering

I'm trying to bring some images from a Tumblr account and to show them using a slider. To bring the images I modified and used a script called tubmlrBadge (http://robertnyman.com/2008/09/19/tumblrbadge-a-tumblr-badge-script/), and to show the images I am using this slider > http://www.meadmiracle.com/SlidingGallery.aspx If I check using Firebug I can see that the photos are shown okay, but I can't see them in with the slider. I can't figure out what's the problem, I suppose that a problem appears because the slider script must work with content generated by the tubmlr script. I tried placing the slider script after the tumblr one the slider still doesn't works. You can see a demo of the this at http://www.mctest2.com.ar. If anyone has an idea please help me I tried everything!! Thanks!

Upvotes: 0

Views: 140

Answers (1)

marcosfromero
marcosfromero

Reputation: 2853

If the script you use to fetch the images was the image-fetcher itself (not a script that calls another script to get a JSON with the image data) you would have used $.getScript with a callback method.

However, your script can't use it, because no matter if the script file is loaded, it will also call another one, that might take longer to be loaded.

I think the only possibility you have is to set an "timer" in your page and wait until the gallery is loaded:

function setSlider() {
    var jqelement = $('.gallery img');
    if(jqelement.length>0) {
        jqelement.slidingGallery();
    } else {
        setTimeout(setSlider, 200);
    }  
}

setSlider();

Working example:

http://jsfiddle.net/marcosfromero/5dSgd/

Upvotes: 1

Related Questions