brianlange Posted January 12, 2011 Share Posted January 12, 2011 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? Quote Link to comment Share on other sites More sharing options...
brianlange Posted January 13, 2011 Author Share Posted January 13, 2011 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(); }); }); } Quote Link to comment Share on other sites More sharing options...
trq Posted January 13, 2011 Share Posted January 13, 2011 Take a look at jQuery's 'live' method. http://api.jquery.com/live/ Quote Link to comment Share on other sites More sharing options...
brianlange Posted January 13, 2011 Author Share Posted January 13, 2011 Sweet thx! I knew jquery wouldn't let me down. 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.