Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #201 from masonjeffreys/rails-ujs
Browse files Browse the repository at this point in the history
Check for rails-ujs object when re-enabling button
  • Loading branch information
kennyadsl authored Jan 29, 2019
2 parents 10c029c + 2d0446c commit 0a050e4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/assets/javascripts/solidus_paypal_braintree/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ $(function() {
* https://github.com/rails/jquery-rails/blob/master/vendor/assets/javascripts/jquery_ujs.js#L517
* The only way we can re-enable it is by delaying longer than that timeout
* or stopping propagation so their submit handler doesn't run. */
if ($.rails) {
if ($.rails && typeof $.rails.enableFormElement !== 'undefined') {
setTimeout(function () {
$.rails.enableFormElement($submitButton);
$submitButton.attr("disabled", false).removeClass("disabled").addClass("primary");
}, 100);
} else if (typeof Rails !== 'undefined' && typeof Rails.enableElement !== 'undefined') {
/* Indicates that we have rails-ujs instead of jquery-ujs. Rails-ujs was added to rails
* core in Rails 5.1.0 */
setTimeout(function () {
Rails.enableElement($submitButton[0]);
$submitButton.attr("disabled", false).removeClass("disabled").addClass("primary");
}, 100);
} else {
$submitButton.attr("disabled", false).removeClass("disabled").addClass("primary");
}
Expand Down

0 comments on commit 0a050e4

Please sign in to comment.