Skip to content

Instantly share code, notes, and snippets.

@warolv
Created October 20, 2013 14:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warolv/7070343 to your computer and use it in GitHub Desktop.
Save warolv/7070343 to your computer and use it in GitHub Desktop.
Rails UJS events handling example using form
$(document)
.on('ajax:beforeSend', '#scheduling_options_form', function() {
console.log('beforeSend');
$('.ajax-loader').show();
})
.on('ajax:success', '#scheduling_options_form', function(data, status, xhr) {
console.log('Success');
$('.ajax-loader').hide();
})
.on('ajax:error', '#scheduling_options_form', function(data, status, xhr) {
console.log('Error');
$('.ajax-loader').hide();
})
= form_for @object, :url => settings_path, :remote => true, :html => {:id => 'scheduling_options_form', :multipart => true} do |f|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment