module SweetAlert2Rails::ViewHelpers

Public Instance Methods

button_tag(*args, &block) click to toggle source
Calls superclass method
# File lib/sweet-alert2-rails/view_helpers.rb, line 22
def button_tag(*args, &block)
  html_options = args[block_given? ? 0 : 1] || {}

  if options_has_confirm?(html_options)
    html_options['data-sweet-alert-confirm'] = html_options.delete(:confirm) ||
                html_options[:data].delete(:confirm)
  end

  super *args, &block
end
submit_tag(value = 'Save changes', options = {}) click to toggle source
Calls superclass method
# File lib/sweet-alert2-rails/view_helpers.rb, line 14
def submit_tag(value = 'Save changes', options = {})
  if options_has_confirm?(options)
    options['data-sweet-alert-confirm'] = options[:data].delete(:confirm)
  end

  super value, options
end

Protected Instance Methods

options_has_confirm?(options) click to toggle source
# File lib/sweet-alert2-rails/view_helpers.rb, line 35
def options_has_confirm?(options)
  options[:data] && options[:data][:confirm]
end