SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast adear11's Avatar
    Join Date
    Oct 2003
    Location
    Richland MS
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding ajax functionality to content loaded via ajax

    I am currently working a site which will use ajax. I have a menu that, when the items are clicked, uses jQuery load() to load a page. It works fine. The problem I am having is that the pages I am loading also have links or forms which need to use ajax. However, since the main page is already loaded when the pages are loaded via ajax, I don't have a chance to assign listeners to the new links or forms. Does that make sense?

    Here is an example. I have a link that says "clients". This link has a click event added via the jquery.ready() function. I can click the link, and the new page will be loaded by ajax. Now, this client page contains a list of links which point to various client functions. I have used a callback function to add the click event to these links. Now, lets say that I click on the "add client" link. This page loads and contains a form. How do I add ajax to this form? I have tried putting a line in the callback function to do it, but it doesn't seem to be called when the page with the form is loaded. It seems to only be called when I click one of the links on the client page.

    I think that if I nest another call back function in the alread nested one, It will work. but that seems like a such a hassle. If this isn't clear I can try to clear it up. Just ask.

    thanks.

  2. #2
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you should find an answer with the Live jQuery plugin:
    http://jquery.com/plugins/project/livequery

  3. #3
    SitePoint Enthusiast adear11's Avatar
    Join Date
    Oct 2003
    Location
    Richland MS
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. This looks like exactly what I need.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •