美文网首页
toastr_rails:不错的notifications

toastr_rails:不错的notifications

作者: kamionayuki | 来源:发表于2016-12-09 20:31 被阅读36次

    toastr_rails是一个基于toastr的gem。toastr的demo
    用法直接看usage就好了。

    1. gem "toastr_rails"
    2. assets/javascripts/application.js中加入//= require toastr_rails
    3. assets/stylesheets/application.js中加入*= require toastr_rails
    4. views/layouts/application.htm.erb中加入<%= render 'toastr_rails/flash' %>
    5. flash[:info] = "hi,there"调用即可

    也可以修改一些options

    1. assets/javascripts/application.js
    toastr.options = {
     "closeButton": false,
     "debug": false,
     "newestOnTop": false,
     "progressBar": false,
     "positionClass": "toast-top-right",
     "preventDuplicates": false,
     "onclick": null,
     "showDuration": "300",
     "hideDuration": "1000",
     "timeOut": "5000",
     "extendedTimeOut": "1000",
     "showEasing": "swing",
     "hideEasing": "linear",
     "showMethod": "fadeIn",
     "hideMethod": "fadeOut"
    }
    

    更多详细的options可以在demo中调试,然后直接复制过来。

    1. assets/stylesheets/application.js中也可以调整样式,比如这样
     #toast-container{
     top: 50px;
    }
    
    

    当然,也可以直接把toastr引入到项目中。

    相关文章

      网友评论

          本文标题:toastr_rails:不错的notifications

          本文链接:https://www.haomeiwen.com/subject/kbkymttx.html