acidglitter Posted March 21, 2009 Share Posted March 21, 2009 I have my regular php page, and it has a div. What I want to happen is when you click a link, the content inside the div is refreshed (the content gets reloaded). If I have the link outside of the div (on the php page), the refresh link works fine. But if I put the link inside the div (so it's part of the loaded content) it doesn't work. I'm using jQuery so my refresh link looks like this.. <a href="" id="refreshpage">refresh</a> The actual script is like $("#refreshpage").click(function(){ $("#box").html('<p>loading..</p>'); $.get("page", function(loadthis){ $("#box").html(loadthis); }); return false; }); Why doesn't the link work when it's part of the loaded content? Is it only because I'm using jQuery? Quote Link to comment https://forums.phpfreaks.com/topic/150503-reloading-content-in-a-div/ Share on other sites More sharing options...
rhodesa Posted March 21, 2009 Share Posted March 21, 2009 where is this JS code? on the parent? you need to run it each time the DIV loads (aka put it in the reloaded content) Quote Link to comment https://forums.phpfreaks.com/topic/150503-reloading-content-in-a-div/#findComment-790510 Share on other sites More sharing options...
Floydian Posted March 21, 2009 Share Posted March 21, 2009 If you have a click event listener attached to the div instead, and then get the target of the event making sure to look for the element id of refreshpage, you wouldn't have to make a new event listener each time the div is loaded. To recap, the click event listener on the div would fire any time the div is clicked, but you would check the target of the click to make sure that it was the link that was clicked, and not something else inside the div. And then you can proceed to reload the div that way. Hope that helps... Quote Link to comment https://forums.phpfreaks.com/topic/150503-reloading-content-in-a-div/#findComment-790583 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.