首页 > 其他 > 详细

消息闪现

时间:2018-01-21 11:50:58      阅读:238      评论:0      收藏:0      [点我收藏+]

消息闪现

放在ApplicationHelper.rb中。在页面面中 <%= nitice_message %>

def notice_message
   flash_messages = []
      flash.each do |type, message|
        type = :success if type.to_sym == :notice
        type = :danger  if type.to_sym == :alert
        text = content_tag(:div, link_to(raw('<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'), '#', :class => 'close', 'data-dismi  ss' => 'alert') + message, class: "alert alert-#{type}")
        flash_messages << text if message
    end
    flah.clear
    flash_messages.join("\n").html_safe
    end

在控制器中:

redirect_to root_url,notice:'hello'

消息闪现

原文:https://www.cnblogs.com/dccmmtop/p/8323581.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!