Skip to content

Instantly share code, notes, and snippets.

@robe5
Created September 14, 2009 18:33
Show Gist options
  • Save robe5/186831 to your computer and use it in GitHub Desktop.
Save robe5/186831 to your computer and use it in GitHub Desktop.
# Rails 3 ajax calls
$(document.body).observe('click', function(event){
var element = event.findElement("a['data-remote']");
if (element) {
var method = element.readAttribute("data-method") || "get";
new Ajax.Request(element.readAttribute("href"), { method: method });
event.stop();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment