I am trying to get a Bootstrap Notify alert to remain visible until the user dismisses it, without it auto-closing. To do this, according to my understanding of the documentation, I set the delay
setting to 0
. This is my JS file that 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 a click
event on a button in the view, but when it's called from a SignalR callback from the server, as below, the alert closes almost instantly as soon as it appears:
var hubProxy = $.connection.applicationHub;
hubProxy.client.alertNewClaim = function (model) {
toasterNotify(model.SourceFullName, model.Message);
};
EDIT:
I have figured out that the controller action involved pushes the SignalR message to the client just before returning a view result. So the client immediately receives the SignalR message and displays the alert, only to have the page refreshed by the returned view, removing the alert quickly. I still have no idea yet how to work around this.