jQuery .load() and sub-pages

Posted by user354051 on Stack Overflow See other posts from Stack Overflow or by user354051
Published on 2010-05-30T16:14:32Z Indexed on 2010/05/30 16:22 UTC
Read the original article Hit count: 420

Filed under:
|

Hi,

I am not just a newbie with Javascript. I am developing a simple site to get my hands on web programming. The web site is simple and structure is like this:

  1. A simple ul/li/css based navigation menu
  2. Sub pages are loaded in "div" using jQuery, when ever user click appropriate menu item.
  3. Some of the sub-pages are using different jQuery based plugins such as LightWindow, jTip etc.

The jQuery function that loads the sub-page is like this:

function loadContent(htmlfile){
    jQuery("#content").load(htmlfile);
};

The menu items fires loadContent method like this:

<li><a href="javascript:void(0)" onclick="loadContent('overview.html');return false">overview</a></li>

This loads a sub-page name "overview.html" inside the "div".

That's it.

Now this is working fine but some of the sub-pages using jQuery based plugins are not working well when loaded inside the "div". If you load them individually in the browser they are working fine.

Based on above I have few qustions:

  1. Most of the plugins are based on jQuery and sub-pages are loaded inside the "index.html" using "loadContent" function. Do I have to call

    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>

    on each and every sub-page?

  2. If a page is using a custom jQuery plugin, then where do I call it? In "index.html" or on the page where I am using it?

  3. I think what ever script you will call in "index.html", you don't to have call them again in any of the sub pages you are using. Am I right here?

Thanks

Prashant

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about load