Jump to content

AJAX driving me nuts :)


herghost

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Thanks :)

 

I honestly did not understand any of that  :o !

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.