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? Link to comment https://forums.phpfreaks.com/topic/224251-programming-in-ajax/ 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(); }); }); } Link to comment https://forums.phpfreaks.com/topic/224251-programming-in-ajax/#findComment-1158650 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/ Link to comment https://forums.phpfreaks.com/topic/224251-programming-in-ajax/#findComment-1158654 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. Link to comment https://forums.phpfreaks.com/topic/224251-programming-in-ajax/#findComment-1158664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.