Jump to content

Programming in ajax.


brianlange

Recommended Posts

I am using zend framework and jQuery.

I have a page with a list of users that can be individually deleted by clicking a link.

A jQuery script is included on this page that adds an ajax call to each "delete user" link.

Inside of the ajax call I use the jQuery load function to refresh the list of users.

The problem is that inside of the "list of users" page (separate zend framework view with no layout)  I have to reinclude the jquery script that assigns the ajax to each delete link.

It works but it seems rather clunky.  Is there a better way to do this? 

 

Link to comment
Share on other sites

I tried to add a recursive call inside of the ajax code but it doesn't seem to work.

assignDeleteLinks is called within "success" but it is not working.

function assignDeleteLinks()
{
    $('.delete-kid').each(function() {
   $(this).click(function(e) {
       $.ajax({type: 'POST',
               url: '/kids/delete/id/' + $(this).attr('rel'),
               success: function() {
                   $('#message').html('Kid has been deleted');
                   $('#kid-list').load('/kids/list/');
                   assignDeleteLinks(); 
               }
       });
               
              
       e.preventDefault();
          
   });
   
});
    
}

 

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.