I'm trying customize the position of the toast.
I tried do that, but it doesn't works:
applications.js
//= require jquery
//= require toastr
//= require jquery_ujs
//= require turbolinks
//= require_tree .
$(document).ready(function() {
toastr.options = {
"closeButton": false,
"debug": false,
"positionClass": "toast-bottom-right",
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
});
I'm using rails 5, anyone know why it doesnt works? Tks in advance.
Do you use toastr-rails?
I've tried use that but I can't do it, so now I'm using toastr directly: https://github.com/CodeSeven/toastr
Just add in application.js so create a partial like that:
<% unless flash.empty? %>
<script type="text/javascript">
<% flash.each do |f| %>
<% type = f[0].to_s.gsub('alert', 'error').gsub('notice', 'info') %>
toastr['<%= type %>']('<%= f[1] %>', '', {"closeButton": false, "debug": false, "positionClass": "toast-bottom-full-width", "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" });
<% end %>
</script>
Note that the options are inline on the code.