2

I am using a template that uses bootstrap-notify and I would like to send data to it from a view:

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)

In this example the message is showing but all the other options like "icon" and "title" are being ignored.

In JS, doing the same thing looks like:

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

Any idea on how to fix this?

4m1nh4j1
  • 4,289
  • 16
  • 62
  • 104
  • 4
    Can you please update the question with the way that you are handling the `JsonResponse`? That may be the problem. – John Moutafis Sep 28 '19 at 12:05
  • 1
    Please update with the code that is receiving that JsonResponse. Your question is unanswerable otherwise. – Lord Elrond Sep 29 '19 at 03:30
  • 1
    What happens here `JsonResponse(options)`? Please share more details so that one can understand the problem – nircraft Oct 01 '19 at 14:02
  • Are you sure that there is nothing overridden your bootstrap-notify css? It would be very helpful if you can take a screenshot and show all messages in the console tab of browser dev tools. – Toan Quoc Ho Oct 02 '19 at 09:30

1 Answers1

0

You can do something like, let http://localhost:8000/notify-options/

$.get("http://localhost:8000/notify-options/", function(data, status){
    $.notify(data,{
        // settings
        type: 'danger'
    });​
});
SHIVAM JINDAL
  • 2,844
  • 1
  • 17
  • 34