Skip to content

Instantly share code, notes, and snippets.

@nachocab
Created July 24, 2009 08:47
Show Gist options
  • Save nachocab/153922 to your computer and use it in GitHub Desktop.
Save nachocab/153922 to your computer and use it in GitHub Desktop.
jQuery.fn.getWithAjax = function() {
this.unbind('click', false);
this.click(function() {
$.get($(this).attr("href"), $(this).serialize(), null, "script");
return false;
})
return this;
};
function ajaxLinks(){
$('.ajaxForm').submitWithAjax();
$('a.get').getWithAjax();
$('a.post').postWithAjax();
$('a.put').putWithAjax();
$('a.delete').deleteWithAjax();
return false;
}
$(document).ready( function(){
ajaxLinks();
});
<% if !@note_groups.blank? %>
$("#note_groups").html("<%= escape_javascript( render :partial => 'note_group', :collection => @note_groups ) %>")
<% else %>
$("#note_groups").html("<%= escape_javascript( render :partial => 'empty_note_group') %>")
<% end %>
#note_groups
=link_to 'Click here to see all note groups", note_groups_path, :class => 'get'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment