Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions vendor/assets/javascripts/jquery_ujs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

// Shorthand to make it a little easier to call public rails functions from within rails.js
var rails;
var $document = $(document);

$.rails = rails = {
// Link elements bound by jquery-ujs
Expand Down Expand Up @@ -279,15 +280,15 @@

};

if (rails.fire($(document), 'rails:attachBindings')) {
if (rails.fire($document, 'rails:attachBindings')) {

$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});

$(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() {
$document.delegate(rails.linkDisableSelector, 'ajax:complete', function() {
rails.enableElement($(this));
});

$(document).delegate(rails.linkClickSelector, 'click.rails', function(e) {
$document.delegate(rails.linkClickSelector, 'click.rails', function(e) {
var link = $(this), method = link.data('method'), data = link.data('params');
if (!rails.allowAction(link)) return rails.stopEverything(e);

Expand All @@ -311,23 +312,23 @@
}
});

$(document).delegate(rails.buttonClickSelector, 'click.rails', function(e) {
$document.delegate(rails.buttonClickSelector, 'click.rails', function(e) {
var button = $(this);
if (!rails.allowAction(button)) return rails.stopEverything(e);

rails.handleRemote(button);
return false;
});

$(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
$document.delegate(rails.inputChangeSelector, 'change.rails', function(e) {
var link = $(this);
if (!rails.allowAction(link)) return rails.stopEverything(e);

rails.handleRemote(link);
return false;
});

$(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
$document.delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
var form = $(this),
remote = form.data('remote') !== undefined,
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
Expand Down Expand Up @@ -362,7 +363,7 @@
}
});

$(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) {
$document.delegate(rails.formInputClickSelector, 'click.rails', function(event) {
var button = $(this);

if (!rails.allowAction(button)) return rails.stopEverything(event);
Expand All @@ -374,11 +375,11 @@
button.closest('form').data('ujs:submit-button', data);
});

$(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
$document.delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
if (this == event.target) rails.disableFormElements($(this));
});

$(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
$document.delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
if (this == event.target) rails.enableFormElements($(this));
});

Expand Down