Skip to content

Instantly share code, notes, and snippets.

View bokmann's full-sized avatar

David Bock bokmann

View GitHub Profile
$(document).ready(function(){
$("#new_comment").submitAndUpdateCollection("#comments")
});
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) {