Skip to content

Commit

Permalink
Update jquery-ujs to latest v1.2.3
Browse files Browse the repository at this point in the history
It contains improved compatibility with turbo.
rails/jquery-ujs#521

Closes #284
  • Loading branch information
carlosantoniodasilva committed Nov 10, 2022
1 parent a80d74b commit 7e6f508
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## unreleased

- update jquery to 3.6.1
- update jquery-usj to 1.2.3

## 4.5.0

Expand Down
2 changes: 1 addition & 1 deletion VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| Gem | jQuery | jQuery UJS | jQuery UI |
|--------|--------|------------| ----------|
| x.x.x | 1.12.4 & 2.2.4 & 3.6.1 | 1.2.2 | - |
| x.x.x | 1.12.4 & 2.2.4 & 3.6.1 | 1.2.3 | - |
| 4.5.0 | 1.12.4 & 2.2.4 & 3.6.0 | 1.2.2 | - |
| 4.4.0 | 1.12.4 & 2.2.4 & 3.5.1 | 1.2.2 | - |
| 4.3.5 | 1.12.4 & 2.2.4 & 3.4.1 | 1.2.2 | - |
Expand Down
2 changes: 1 addition & 1 deletion lib/jquery/rails/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module Rails
JQUERY_VERSION = "1.12.4"
JQUERY_2_VERSION = "2.2.4"
JQUERY_3_VERSION = "3.6.1"
JQUERY_UJS_VERSION = "1.2.2"
JQUERY_UJS_VERSION = "1.2.3"
end
end
26 changes: 18 additions & 8 deletions vendor/assets/javascripts/jquery_ujs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function($, undefined) {
/* jshint node: true */

/**
* Unobtrusive scripting adapter for jQuery
Expand All @@ -10,10 +10,13 @@
*
*/

// Cut down on the number of issues from people inadvertently including jquery_ujs twice
// by detecting and raising an error when it happens.
(function() {
'use strict';

var jqueryUjsInit = function($, undefined) {

// Cut down on the number of issues from people inadvertently including jquery_ujs twice
// by detecting and raising an error when it happens.
if ( $.rails !== undefined ) {
$.error('jquery-ujs has already been loaded!');
}
Expand All @@ -33,10 +36,10 @@
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',

// Form elements bound by jquery-ujs
formSubmitSelector: 'form',
formSubmitSelector: 'form:not([data-turbo=true])',

// Form input elements bound by jquery-ujs
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])',
formInputClickSelector: 'form:not([data-turbo=true]) input[type=submit], form:not([data-turbo=true]) input[type=image], form:not([data-turbo=true]) button[type=submit], form:not([data-turbo=true]) button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])',

// Form input elements disabled during form submission
disableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled',
Expand Down Expand Up @@ -372,7 +375,7 @@
element.html(replacement);
}

element.bind('click.railsDisable', function(e) { // prevent further clicking
element.on('click.railsDisable', function(e) { // prevent further clicking
return rails.stopEverything(e);
});
element.data('ujs:disabled', true);
Expand All @@ -384,7 +387,7 @@
element.html(element.data('ujs:enable-with')); // set to old enabled state
element.removeData('ujs:enable-with'); // clean up cache
}
element.unbind('click.railsDisable'); // enable element
element.off('click.railsDisable'); // enable element
element.removeData('ujs:disabled');
}
};
Expand Down Expand Up @@ -552,4 +555,11 @@
});
}

})( jQuery );
};

if (window.jQuery) {
jqueryUjsInit(jQuery);
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = jqueryUjsInit;
}
})();

0 comments on commit 7e6f508

Please sign in to comment.