zoukankan      html  css  js  c++  java
  • json数据 提示框flash.now[:notice] flash.now[:alert]

    实现json、做出提示框

    1、在controller中使用flash.now[:alert] = "str"方法来做print

    def topodata
      #@vnic = Vnic.all
      #flash.now[:notice] = 'Message sent!'
      #flash.now[:alert] = 'Message sent!'
      @vnic = {
        nodes: [{ name: 'bob', age: "22", awesome: "true" }, { name: 'bob', age:      22, awesome:true }],
    links: [{ name: 'bob', age: "22", awesome: "true" }, { name: 'bob', age: 22,  awesome:true }]
      }
      flash.now[:alert] = @vnic
      respond_to do |format|
        format.html
        format.json { render json: @vnic } #这里会自动调用to_json
      end
    end
    

      

    2、在view中使用链接来做提示 alert也可以换做confirm

    <a href= 'http://192.168.1.251:3000/vnets'  onclick="return(alert('<%= current_user.email %>'))">删除</a>

  • 相关阅读:
    iPhone iPad发展史
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
    iOS 学习
  • 原文地址:https://www.cnblogs.com/juandx/p/3955103.html
Copyright © 2011-2022 走看看