PDA

View Full Version : Ajax Tabs Content Script (v 2.2) Using External Html with Javascripts



bridge
09-19-2010, 06:14 PM
1) Script Title: Ajax Tabs Content Script (v 2.2)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/

3) Describe problem:

I am a newbie. When I load content from external html containing javascript, the javascript does not execute. I created a simple test page displaying the date in a box (div). When I load this into the tab content div, it displays the box (div) but, not the date (javascript). I have more complicated javascripts in the external html pages that do not show either. Is there a way to execute the javascript in external pages?

molendijk
09-19-2010, 10:51 PM
That's because the script uses innerHTML to include external content.
If you put the javascript of the external files in the head of the main page (demo.htm, in this case), then the javascript will execute.
===
Arie Molendijk.

jscheuer1
09-19-2010, 11:28 PM
Yes, that's true. You may also need to initialize imported content before it will work with the scripts Arie has correctly instructed you put on the 'top' page.

To do that the Ajax Tabs script has an optional onajaxpageload property that you can configure if necessary to initialize newly arrived content, example using a typical init:


var countries=new ddajaxtabs("countrytabs", "submain_gallery")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.onajaxpageload = function(pageurl){
$("a[rel=example_group]").fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'titlePosition' : 'over',
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
}
});
};
countries.init()

In the above, the highlighted is initializing fancybox. You may replace that highlighted code with whatever is required (if anything) to initialize your imported content. Notice the red pageurl argument. It's not required in the above example. It contains a reference to the url of the page that was loaded. This can be helpful in some cases. For more information, see:

http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/ajaxtabs_suppliment3.htm