This topic contains 3 replies, has 2 voices, and was last updated by  jbrahy 10 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • storing data with a tooltip #65942

    jbrahy
    Participant

    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(){});
    });
    storing data with a tooltip #65946

    jbrahy
    Participant

    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);

    storing data with a tooltip #65991

    Dimitar
    Participant

    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 and autoClose: 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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    storing data with a tooltip #66025

    jbrahy
    Participant

    ok, thanks. This solution worked great for me.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.