jQuery UI Widgets › Forums › Dialogs and Notifications › Tooltip, Notification, Popover › storing data with a tooltip
Tagged: attribute, autoClose, autoOpen, close, data, jqxNotification, Notification, open
This topic contains 3 replies, has 2 voices, and was last updated by jbrahy 10 years, 2 months ago.
-
Author
-
If a user closes a notification I don’t want to show it to them again but if they don’t close it I want to show it until they do close it. To accomplish this I would like to add a bit of data to the notification.
var known_alerts = new Array(); $("#jqxNotification").jqxNotification({ width: 350, position: "top-right", opacity: 0.9, autoOpen: false, animationOpenDelay: 800, autoClose: false, template: "info" }); function recent_alerts() { $.get("/alerts/recent", function (alerts, status) { alerts = JSON.parse(alerts); //known_alerts; for (alert_index = 0; alert_index < alerts.length; alerts++) { alert = alerts[alert_index]; if (typeof known_alerts[alert.alert_log_id] == 'undefined') { known_alerts[alert.alert_log_id] = alert; $("#notificationContent").html(alert.alert + " @ " + alert.result_value); $("#jqxNotification").jqxNotification("open"); } } }); } // call immediately and then repeat every 15 seconds recent_alerts(); setInterval(recent_alerts, 15000);
What’s the best way to accomplish this? Should I just add attr(“alert_log_id”,alert.alert_log_id) to the notificationContent?
This is my html
<div id="jqxNotification"> <div id="notificationContent"> </div> </div>
This is what I was considering as a solution but wanted to see what the best jqwidgets way to accomplish this would be.
$("#jqxNotification").on("close", function (event) { alert_log_id = $(event.currentTarget).attr("alert_log_id"); $.get("/alerts/acknowledge/" + alert_log_id, function(){}); });
not sure why I called it a tooltip. Feel free to change the title to notification.
and forgot to add this into the for loop
$("#jqxNotification").attr("alert_log_id", alert.alert_log_id);
Hello jbrahy,
If it suits your implementation, you are free to add custom attributes to the jqxNotification div. However, if you only wish to show a notification only once until it is closed, I suggest you create one with the properties
autoOpen: true
andautoClose: false
– this way only one notification will be created (do not call the open method) and it will stay until closed by the user.Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ok, thanks. This solution worked great for me.
-
AuthorPosts
You must be logged in to reply to this topic.