Created
October 16, 2011 21:38
-
-
Save jeffreyiacono/1291454 to your computer and use it in GitHub Desktop.
Rails 3 UJS Remote JavaScript callbacks (example)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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