views:

62

answers:

1

Hi, I'm using the jQuery UI Tabs plug-in to load html pages via ajax, so I have the following html:

<div id="tabs">
   <ul>
      <li><a href="pageWithGallery.html" title="pageWithGallery">Gallery</a></li>
   </ul> 
</div>

The loaded page pageWithGallery.html contains a jQuery gallery which plays on $(document).ready. this however doesn't work when the ui-tabs plug-in loads the page via ajax . How then should I do this? Thanks!

+1  A: 

You can initialize the jQuery gallery on tab load.

$('#tabs').tabs({
   load: function(event, ui) {
      // load gallery ...
   }
});
Christoffer
Thanks, So this will run each time a tab is selected not just the one with the gallery, can i specify to run it only when a specific tab is selected? Also this requires me to load the script to my main page (containing the tabs) and have knowledge about the tabs content can I avoid this?
gkdm
Yes, you can make it run on only certain occasions, but that would make it very undynamic since you need to have knowledge about exactly which tabs you have. Run console.log(ui) to see what options you have to match against. If you are running Firefox with Firebug or Safari/Chrome and know how to use the console.
Christoffer
Another option might be to load an iframe in the tab instead...
Christoffer