Skip to content

Instantly share code, notes, and snippets.

@bokmann
Created March 4, 2010 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bokmann/321282 to your computer and use it in GitHub Desktop.
Save bokmann/321282 to your computer and use it in GitHub Desktop.
jQuery.fn.submitAndUpdateCollection = function(collection_id) {
$(this).submit(function() {
$.ajax({
type: 'post',
url: $(this).attr("action"),
beforeSend: function (xhr) {
xhr.setRequestHeader("Accept", "text/html-partial")
},
data: $(this).serialize(),
success: function(partial) {
$(collection_id).append(partial);
$(collection_id + ' div:last-child').effect("highlight", {}, 3000);
$(this).reset();
}
});
return false;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment