I am trying to get a Bootstrap Notify warning to stay visible until the user rejects it, without automatically closing it. To do this, according to my understanding of the documentation, I set the delay parameter to 0 . This is my JS file, which is included after bootstrap-notify.js :
$(function () { var alertTemplate = $("#notify-template").html(); $.notifyDefaults({ target: "_self" }, { type: "warning", delay: 0, template: alertTemplate }); }); var toasterNotify = function (alertTitle, alertMessage, alertUrl) { alertUrl = alertUrl || "#"; $.notify({ title: alertTitle, message: alertMessage, url: alertUrl }, { delay: 0 }); }
This toasterNotify function works exactly as expected when I call it directly from the click event on the button in the view, but when it is called from the SignalR callback from the server, as shown below, the warning closes almost instantly as soon as it appears:
var hubProxy = $.connection.applicationHub; hubProxy.client.alertNewClaim = function (model) { toasterNotify(model.SourceFullName, model.Message); };
EDIT:
I realized that the action of the controller includes a SignalR message to the client immediately before returning the result of the view. Thus, the client immediately receives a SignalR message and displays a warning, only to refresh the page on the returned view, quickly removing the warning. I still don't know how to get around this.
javascript twitter-bootstrap bootstrap-notify
Profk
source share