Closed marcosvicente closed 6 years ago
I use this in my application.haml:
:javascript
var toastNoticeContent = "#{notice}";
var toastAlertContent = "#{alert}";
var toastErrorContent = "#{error}";
Then, in a JS file loaded on every request:
if(toastNoticeContent != ""){
Materialize.toast(toastNoticeContent, 6000)
}
if(toastAlertContent != ""){
Materialize.toast(toastAlertContent, 6000, "alert")
}
if(toastErrorContent != ""){
Materialize.toast(toastErrorContent, 10000, "error")
}
@mikewagz - out of curiosity, how are you serving up that JS file on every request?
@rubendinho - I use a common.js
file that is loaded from my application.js
file like this:
//= require jquery
//= require jquery_ujs
// .. other libraries, etc.
//= require common
//= require_tree ./components
//= require_tree ./pages
toaster helper now available at master branch :)
I want to include with notice, that I am using the gem device . <%= notice %> How do make a toasts. Thanks for help.