Krafton,

>I'm using this code in jquery to load  the content of a div
>(primaryContentContainer) by cliking on <a href...
>
>$(document).ready(function()
>     {
>         $("a").click(function()
>              {
>                    var link=$(this).attr("id");
>                    $("#primaryContentContainer").load("pages/"+link
>+".html");
>              };
>} );
>
>I'm using this kind of link :  <a href="#" id="dos622">Dos v6.22 boot
>disk</a>
>
>It's working fine, but if i put a link in a page that's loaded
>by .load(), the link seems not working.
>
>Exemple: clicking on <a href="#" id="dos622">Dos v6.22 boot disk</a>
>load the page dos622.html in the div with
>id="primaryContentContainer". But the same (or other) link if
>contained in dos622.html will not work.
>
>I don't have much experience with jquery, can someone help me please?

If I understand you correctly, you're saying that if the "dos622.html" file
contains links, it's not picking up the click handler, correct?

If so, this is the expected behavior. When you run a jQuery function it only
runs for elements currently in the DOM. If you create new DOM
elements--manually or by loading a DOM fragment via AJAX--you would need
call the code to re-initialize click handler for the new content. You can do
this via a callback.

However, you're probably going to run into another issue. The "id" attribute
must be unique. This means you can't have more than one element in the DOM
with an "id" of "dos622". The way that you're currently using the code, you
may not run into a problem, but if you'd do a $("#dos622"), you'd only get
back a single node.

-Dan

Reply via email to