From e9aa7ecdee0aa7bb4dcfa5046881bde2f1fe21cc Mon Sep 17 00:00:00 2001 From: Mathieu Date: Sun, 1 Apr 2018 19:15:36 +0700 Subject: Extract the confirm call in its own, overridable method in rails_ujs --- actionview/app/assets/javascripts/rails-ujs/features/confirm.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'actionview/app') diff --git a/actionview/app/assets/javascripts/rails-ujs/features/confirm.coffee b/actionview/app/assets/javascripts/rails-ujs/features/confirm.coffee index 72b5aaa218..0738ffcdc9 100644 --- a/actionview/app/assets/javascripts/rails-ujs/features/confirm.coffee +++ b/actionview/app/assets/javascripts/rails-ujs/features/confirm.coffee @@ -5,6 +5,10 @@ Rails.handleConfirm = (e) -> stopEverything(e) unless allowAction(this) +# Default confirm dialog, may be overridden with custom confirm dialog in Rails.confirm +Rails.confirm = (message, element) -> + confirm(message) + # For 'data-confirm' attribute: # - Fires `confirm` event # - Shows the confirmation dialog @@ -20,7 +24,7 @@ allowAction = (element) -> answer = false if fire(element, 'confirm') - try answer = confirm(message) + try answer = Rails.confirm(message, element) callback = fire(element, 'confirm:complete', [answer]) answer and callback -- cgit v1.2.3