thecodeholic/lobibox

Question: Is there a way to prevent page refresh to close the message?

lenamtl opened this issue · 1 comments

Hi,
I have a form, the page refresh every 60 seconds the data is temporary saved in localstorage.
When the form is submit the success message box appear but may disappear quickly if a refresh arrive at the same time, so is there anything that can prevent this.

Let say I set a delay before hiding the message box and keep the message box open even if there is a page refresh?

He lenamtl,
Sorry for my late response.
This is obviously non standard task. Of course there is no direct implementation. But I think there is a solution for this.

The idea is that you must save how much time passed after notification shown before page load and on page load you must show the same notification for remained time.

var delayTime = 7000;
Lobibox.notify('default',{
    msg: 'Your message',
    delay: delayTime
});
var elipsedTime = 0;
var intervalDuration = 30;
// Save notification options in localstorage
setInterval(function(){
    elipsedTime += intervalDuration;
    // Save elipsedTime in localStorage
}, intervalDuration);

// Script on page load
var notificationParams = getNotificationParams(); //Read notification params from localstorage
// Show notification if notificationParams exist
Lobibox.notify('default', notificationParams);

Let me know if you need more help