Adding onload event to AJAX loaded div

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nicky77
    New Member
    • Aug 2007
    • 25

    Adding onload event to AJAX loaded div

    Hi, I'm trying to integrate a photo gallery into a site where the content section of the page is loaded using AJAX. I'm using Lightbox for the gallery and although the gallery works fine as a separate page, I now need to add the following events to the <div> containing the gallery:
    Code:
    onload="focus_first_input(); initLightbox();"
    Does anyone know how I can add these to the <div> whenever it is loaded?

    Currently the code is as follows on the top page:
    Code:
    <ul id="nav">
    <li id="navLineup"><a href="javascript:ajaxpage('lineup.php', 'content_right');">Lineup</a></li>
    	<li id="navStages"><a href="javascript:ajaxpage('retrostages.php', 'content_right');">Stages</a></li>
    	<li id="navGallery"><a href="javascript:ajaxpage('gallery_index.php?level=album&id=1', 'content_right');" onclick="focus_first_input(); initLightbox();">Gallery</a></li>
    	<li id="navRetrospective"><a href="javascript:ajaxpage('retrospective.php', 'content_right');">Gallery</a></li>
    </ul>
    the placeholder div....
    Code:
    <div id="content_right"></div>
    and the loaded gallery...
    Code:
    <div id="content_right">
    <h1 id="retrovision">Retro vision</h1>
    <div id="subcontent">
    <?php
    require("gallery.php"); 
    the_gallery(); 
    ?>
    </div>
    </div>
    Grateful for any help!
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    onload for an Ajax loaded div would be when the readyState is 4. Add this code to the callback function which is called when the response is complete.

    Comment

    Working...