Module: ApplicationHelper
- Defined in:
- app/helpers/application_helper.rb
Instance Method Summary collapse
-
#flash_messages(text, warning = false, javascript = false) ⇒ Object
Render HTML flash messages callout.
- #form_error_callout(form_id) ⇒ Object
Instance Method Details
#flash_messages(text, warning = false, javascript = false) ⇒ Object
Render HTML flash messages callout
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/application_helper.rb', line 15 def (text, warning=false, javascript=false) html = <<-messages <div id="flash" class="callout #{warning ? 'warning' : 'secondary' }" data-closable> REPLACEME <button class="close-button" aria-label="Dismiss alert" type="button" data-close> <span aria-hidden="true">×</span> </button> </div> messages if javascript js = html.split("\n").map(&:strip).join("'+'") return js.sub(/'REPLACEME'/, text) else html.sub!(/REPLACEME/, text) return html.html_safe end html.html_safe end |
#form_error_callout(form_id) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'app/helpers/application_helper.rb', line 2 def form_error_callout(form_id) form_callout = <<-ajax_error $('form##{form_id}').bind('ajax:error', function(evt, data, status, xhr){ $("#messages").html( '#{('data.responseJSON.join("<br/>")', true, true)}' ); $('#messages').foundation('open'); }) ajax_error form_callout.html_safe end |