bphein1980
10-13-2010, 07:08 PM
$(document).ready(function(){
// objFile = path to file
// objLoad = ID of div/span/etc I want new content loaded in
function loadContent(objFile, objLoad){
$("#"+objLoad).load(objFile);
}
// all nextpage classes should use the loadContent function
$(".nextpage").click(function(e){
e.preventDefault();
loadContent($(this).attr('href'), $(this).attr('load'));
});
});
Example usage:
<div id="response">
<a href="page1.cfm" class="nextpage" load="response">Go to page 1</a>
</div>
Contents of page1.cfm:
You are on page1.
<a href="page2.cfm" class="nextpage" load="response">Go to page 2</a>
Clicking "go to page 1" works fine and loads page1.cfm content into the "response" div. However when I click on "go to page 2", it uses the default behavior and just redirects the browser instead of using the jQuery loadContent() function.
Why? and how to get content inserted via .load() to "use" the jQuery?
Thanks!
// objFile = path to file
// objLoad = ID of div/span/etc I want new content loaded in
function loadContent(objFile, objLoad){
$("#"+objLoad).load(objFile);
}
// all nextpage classes should use the loadContent function
$(".nextpage").click(function(e){
e.preventDefault();
loadContent($(this).attr('href'), $(this).attr('load'));
});
});
Example usage:
<div id="response">
<a href="page1.cfm" class="nextpage" load="response">Go to page 1</a>
</div>
Contents of page1.cfm:
You are on page1.
<a href="page2.cfm" class="nextpage" load="response">Go to page 2</a>
Clicking "go to page 1" works fine and loads page1.cfm content into the "response" div. However when I click on "go to page 2", it uses the default behavior and just redirects the browser instead of using the jQuery loadContent() function.
Why? and how to get content inserted via .load() to "use" the jQuery?
Thanks!