Bootstrap Notify autocomplete, even with a delay set to 0

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.

+7
javascript twitter-bootstrap bootstrap-notify
source share
1 answer

My hacked workaround for this is the queue to send a message to the database before sending it to the controller, and then request the client for messages that are not marked as β€œfired” each time the page loads. Thus, the user will see a message on each page that they visit, forever, until he clicks the close button in the message, as a result of which the request will be sent to the Messaging controller to mark this message as β€œrejected”.

0
source share

All Articles