views:

35

answers:

2

Hi, I created an index.html page that have 3 different tab. With the function tabs() of jqueryui I want load with ajax an html page. Every html page use jquery library, so every page have this code:

<link type="text/css" href="css/redmond/jquery-ui-1.8.5.custom.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery-1.4.3.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.5.custom.min.js"></script>

If I click on a tab the page is loaded but the javascript function of the page not works!

So can I load in a tabs a new complete html page? html+js?

A: 

two possibilities:

1) if you need jquery-ui in each tab, it's better to load it when initalizing your tabs.

2) use following to load your javascript files:

$.getScript("js/jquery-ui-1.8.5.custom.min.js");
and for css:
$.get("css/redmond/jquery-ui-1.8.5.custom.css", function(css) {
$("head").append(""+css+"");
}); 

Edit: You never load a complete new html page with ajax tabs - you only load a code snippet which is included in your existing html page. Use Firebug for Mozilla Firefox to see what happens ;o)

Tobias Bambullis
Why i never load a new html page? What is the problem?
in fact, you load a new html page - but it's not very clever to load a document which looks like that: <html><head> [...] because you include this document in your already existing document; so you have it twice. As a result of that, you can't access to the <head> tag to include scriptfiles. Instead you can use $.getScript().
Tobias Bambullis
So, if i understand if when i click on a tab, the content of a link page is added to the page? So if i have two tabs that link the same html page, the second tab not works becouse the DOM content is just place in the first tab! So how can i load a content and remove the previous dom?
you don't have to delete previous content, this happens automatically. If you want to prevent that the same javascript code is loaded twice, set a variable that it was loaded...
Tobias Bambullis
A: 

Ok, the problem is understand what the tabs doing. With the ajax i can load some content in a tab. If i declare a for a tab, the ajax load the content in that so i can't load a new complete html page becouse the dom after the load have two open ecc.

So now i understand the function of the ajax in the tab, and tha load of complete html page is a big mistake!

Thank's for Tobias.