herghost Posted March 3, 2009 Share Posted March 3, 2009 Hi all, I am sure this is quite simple but it really is driving me nuts! I have this small peice of code: <script type="text/javascript"> var GB_ROOT_DIR = "box/greybox/"; </script> <script type="text/javascript" src="box/greybox/AJS.js"></script> <script type="text/javascript" src="box/greybox/AJS_fx.js"></script> <script type="text/javascript" src="box/greybox/gb_scripts.js"></script> Which goes in the head tag of a page and is called by something like this: <a href="http://google.com/" title="Google" rel="gb_page_center[500, 500]">Launch Google.com</a> which basically launches a popup in the middle of the screen. Now here comes the bit that is driving me nuts! If I place this on a standard .php page, it works great, however, I have a page which is controlled by ajax's call page, basically displaying a page within the page by the <div> tags. So index.php will put content.php in a maincontent div tag. When I place the above code in content.php and it is displayed from index.php it does not work! What happens is the link appears, and when you click it, it opens the link in _self instead of bringing up the pop up box. So basically what is causing this? I am guessing that it is something to do with ajax, just dont understand where to start! Hope this is clear enough and thanks in advance Quote Link to comment Share on other sites More sharing options...
corbin Posted March 3, 2009 Share Posted March 3, 2009 It looks like the DOM is being looped through when the page loads, and an onclick listener is being added to every element with the rel="gb_...." thing. So, the looping is already done by the time that AJAX content gets there. So, you will either need to rerun the function that handles the links, or you will need to make something to handle the links that are returned in the AJAX content. Quote Link to comment Share on other sites More sharing options...
herghost Posted March 3, 2009 Author Share Posted March 3, 2009 Thanks I honestly did not understand any of that ! I think that what you have said means that for some reason the java call is being ignored, because it has already been run? How would I go about getting the function to rerun? Sorry I am not more clued up on this, I have been looking at ajax for exactly 4 days Thankls once again Quote Link to comment Share on other sites More sharing options...
corbin Posted March 4, 2009 Share Posted March 4, 2009 Ahhhh.... Plain terms: When the page loads, the JS code loops through, finds all of the <a> tags formatted a certain way and hooks a function to them. (Makes it so that when the <a> is clicked, a function is fired off.) The AJAX content is loaded after the function hooking is done, so you will need to make the links in the AJAX content have the function hooked to them somehow or other. Quote Link to comment 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.