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 = " <div id=\"flash\" class=\"callout \#{warning ? 'warning' : 'secondary' }\" data-closable>\n REPLACEME\n <button class=\"close-button\" aria-label=\"Dismiss alert\" type=\"button\" data-close>\n <span aria-hidden=\"true\">×</span>\n </button>\n </div>\n messages\n if javascript\n js = html.split(\"\\n\").map(&:strip).join(\"'+'\")\n return js.sub(/'REPLACEME'/, text)\n else\n html.sub!(/REPLACEME/, text)\n return html.html_safe\n end\n html.html_safe\nend\n" |
#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 = " $('form#\#{form_id}').bind('ajax:error', function(evt, data, status, xhr){\n $(\"#messages\").html(\n '\#{flash_messages('data.responseJSON.join(\"<br/>\")', true, true)}'\n );\n $('#messages').foundation('open');\n })\n ajax_error\n form_callout.html_safe\nend\n" |