Reputation: 2338
I'm trying to get my javascript to work on pages I load through the .load command.
$("#loadingDockShotPg").load("include/shot_comments.php");
I'm doing this to load a subsection of a page, but the problem is, the div within the newly loaded page isn't being affected by my jQuery file that I have in the parent file. What is a better way to load content so that the newly injected can be affected by my javascript?
Upvotes: 0
Views: 82
Reputation: 5210
I'm assuming that you're issue is with event listeners.
If, for example you're using:
$('.something').click(function(){
// DO SOMETHING
});
Try changing it out for:
$(document).on('click','.something',function(){
// DO SOMETHING
});
This way the jQuery will listen for any clicks on the document and apply the action to events that match clicking on the .something
object.
Upvotes: 3