$(document).ready(function(){
  $('form[data-remote=true]').on('submit', function(e){
    var method, form, action, methodOveride, params;
    form = $(this);
    action = form.attr("action");
    method = form.attr("method");
    method = method || 'get';
    params = form.serialize();
    if(params.match(/_method=delete/));
      if(!confirm('are you sure?')) return false;

    $.ajax({
      url: action,
      data: params,
      type: method
    }).done(function(response, xhr){
      form.parents("li").remove();
    });

    e.preventDefault();
  })
})

@@ -22,16 +22,41 @@
 ction()%7B
+%0A%0A  // Remote form hadler
 %0A  $('fo
@@ -498,16 +498,22 @@
 esponse,
+ stat,
  xhr)%7B%0A 
@@ -526,69 +526,265 @@
 orm.
-parents(%22li%22).remove();%0A    %7D);%0A%0A    e.preventDefault();%0A  %7D)
+trigger('ajax:success', %5Bresponse, stat, xhr%5D);%0A    %7D);%0A%0A    e.preventDefault();%0A  %7D)%0A%0A  // On the delete form, remove the parent LI on success%0A  $('form.delete').on('ajax:success', function(e, response, stat, xhr)%7B%0A    $(this).parents(%22li%22).remove();%0A  %7D);
 %0A%7D)%0A

Make the data remote js more generic, triggers events