{"issue":{"created_at":"2011-11-18T01:43:14Z","state":"closed","updated_at":"2011-11-18T15:22:31Z","comments":3,"user":{"gravatar_id":"52edd2ea78846730ede85cb9f036176a","id":278540,"url":"https://api.github.com/users/easychris","login":"easychris","avatar_url":"https://secure.gravatar.com/avatar/52edd2ea78846730ede85cb9f036176a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"Hey.\r\n\r\nToday I upgraded from jquery-rails gem 1.0.16 to 1.0.17. I found out that the \"ajax:complete\" event is not always triggered anymore. \r\n\r\nI prepared a simple Rails app to show the problem:\r\n<https://github.com/easychris/jquery17-rails-ujs-broken>\r\n\r\nIn application.js I want to trigger all ajax:complete events for existing and new forms (hence the .live call):\r\n\r\n```javascript\r\n$(function() {\r\n  $('form').live('ajax:complete', function() {\r\n    alert('ajax:complete event triggered');\r\n  });\r\n});\r\n```\r\n\r\nI prepared two sample data-remote=true forms, one page using jQuery 1.6.4, the other 1.7. The ajax call simply returns javascript code to replace the existing form by another form (in real life the new form would contain error messages etc). \r\n\r\n```javascript\r\n$('#test_form_container').html(' <%= j (render :partial => 'form')  %> ');\r\n```\r\n\r\n\r\n\r\nWhen using jQuery 1.6.4 the ajax:complete event gets triggered, but unfortunately not using 1.7. I found out that in jquery-ujs the line \r\n\r\n```javascript\r\nelement.trigger('ajax:complete', [xhr, status]);\r\n```\r\n\r\ngets called, but it doesn't trigger any event. I guess because the form to which the ajax event belongs doesn't exist anymore (as it got replaced by the new form). But it should work, as I use the .live event to bind the event to any form-tag. And it does work in 1.6.4. \r\n\r\nAny ideas? I tried a couple of hours to find the error, without success. Maybe someone else already has an idea? \r\n\r\n","assignee":null,"id":2276073,"number":223,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[{"name":"investigate","color":"f5ea1b","url":"https://api.github.com/repos/rails/jquery-ujs/labels/investigate"}],"title":"Event ajax:complete does not get triggered  after form-replacement","closed_at":"2011-11-18T15:22:31Z","html_url":"https://github.com/rails/jquery-ujs/issues/223","milestone":null,"url":"https://api.github.com/repos/rails/jquery-ujs/issues/223"},"action":"closed"}