loading HTML fragments with jQuery
Posted
by sam
on Stack Overflow
See other posts from Stack Overflow
or by sam
Published on 2010-05-06T17:57:07Z
Indexed on
2010/05/06
18:38 UTC
Read the original article
Hit count: 343
Hi everybody,
I'm very new to jQuery, Ajax and things like these. I've found solutions on how to inject HTML fragments into my site:
$(document).ready(function(){
$('a').click(openContent); //binding all anchors to this function
});
function openContent(){
var path = $(this).attr('href');
$('#content').load(path);
return false; //to prevent browser from loading the single HTML fragment
}
That works really fine! The problem is, these function won't be executed when clicking on anchors located in the new HTML fragment which were injected right before. So the fragment won't get injected into div, the browser will only load the fragment for itself.
Hope there are solutions which aren't that tricky... thanks
sam
© Stack Overflow or respective owner