【问题标题】:Send data to bootstrap-notify from a backend code从后端代码发送数据到 bootstrap-notify
【发布时间】:2020-01-24 19:37:34
【问题描述】:

我正在使用一个使用bootstrap-notify 的模板,我想从视图向它发送数据:

try:
    # things
except Exception as e:
    options = {
                    "icon": "glyphicon glyphicon-warning-sign",
                    "title": "Bootstrap notify",
                    "message": "Turning standard Bootstrap alerts into 'notify' like notifications",
                    "url": "https://github.com/mouse0270/bootstrap-notify",
                    "target": "_blank"
                }
    return JsonResponse(options)

在此示例中,消息正在显示,但“图标”和“标题”等所有其他选项都被忽略了。

在 JS 中,做同样的事情看起来像:

$.notify({
// options
message: 'Hello World' ,
title: 'your title'
},{
// settings
type: 'danger'
});​

知道如何解决这个问题吗?

【问题讨论】:

  • 您能否用您处理JsonResponse 的方式更新问题?这可能是问题所在。
  • 请使用接收该 JsonResponse 的代码进行更新。否则您的问题将无法回答。
  • 这里发生了什么JsonResponse(options)?请分享更多细节,以便人们了解问题
  • 你确定没有任何东西覆盖你的引导通知 css 吗?如果您可以截屏并在浏览器开发工具的控制台选项卡中显示所有消息,那将非常有帮助。

标签: javascript django twitter-bootstrap bootstrap-notify


【解决方案1】:

你可以这样做,让http://localhost:8000/notify-options/

$.get("http://localhost:8000/notify-options/", function(data, status){
    $.notify(data,{
        // settings
        type: 'danger'
    });​
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-18
    • 2022-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多