Reply – Re: Documents loaded through ajax, shadowbox not working
Your Name
Subject
Message
or Cancel
In Reply To
Re: Documents loaded through ajax, shadowbox not working
— by Wizzud Wizzud
You have to understand at least the fundamentals of what you doing.

The buzzati.htm file that you are loading by ajax is inserted into the current page's DOM, within div#pagina.
Your buzzati.htm has the shadowbox script and css files included into it, and window.onload stuff as well. Don't need it! Get rid of it! It's already in your main page!

Oh, and take out the onclick on your first image - the buzz2 one.

The ajax script you are using does not have a 'success' callback, so edit the loadpage() function and insert a Shadowbox.setup() call, eg...

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText;
Shadowbox.setup();
}

This isn't the most efficient way of doing it because it will scan the whole DOM when it doesn't really need to, but at least it should get you going.

You have lifted code from Michael's Shadowbox documentation page - the initDemos stuff - none of it is relevant to your page so take it out.
Just keep the ...
  window.onload = function(){
    Shadowbox.init();
  };

Combine literacy with curiosity and a whole world of information opens up to you