Skip to content

Instantly share code, notes, and snippets.

@jeffreyiacono
Created October 16, 2011 21:38
Show Gist options
  • Save jeffreyiacono/1291454 to your computer and use it in GitHub Desktop.
Save jeffreyiacono/1291454 to your computer and use it in GitHub Desktop.
Rails 3 UJS Remote JavaScript callbacks (example)
// via: http://www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/
jQuery(function($) {
// create a convenient toggleLoading function
var toggleLoading = function() { $("#loading").toggle() };
$("#tool-form")
.bind("ajax:loading", toggleLoading)
.bind("ajax:complete", toggleLoading)
.bind("ajax:success", function(event, data, status, xhr) {
$("#response").html(data);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment