This is a migrated thread and some comments may be shown as answers.

Client side hide() doesn't always work on first call

1 Answer 71 Views
Notification
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 2
John asked on 17 Dec 2013, 03:38 PM
I've implemented the Session Expiration example using the RadNotification.
However, I've noticed that users often have to click the "Continue Session" button several times
before the modal closes. I've worked around this by continuing to call notification.hide() until
notification.isVisible() is no longer true. This workaround  appears to work, but I would like to see a
 fix for this in the future.

function ContinueSession() {
     
    var notification = $find("ctl00_SessionTimeoutRadNotification");
     
    //we need to contact the server to restart the Session - the fastest way is via callback
    //calling update() automatically performs the callback, no need for any additional code or control   
    sessionKeepAlive();
    var attempts = 0;
    while (notification.isVisible()) {
        notification.hide();
        attempts++;
    }
    console.log("Took " + attempts + " attempts to close");
    //resets the showInterval for the scenario where the Notification is not disposed (e.g. an AJAX request is made)
    //You need to inject a call to the ContinueSession() function from the code behind in such a request
    var showIntervalStorage = notification.get_showInterval(); //store the original value
    notification.set_showInterval(0); //change the timer to avoid untimely showing, 0 disables automatic showing
    notification.set_showInterval(showIntervalStorage); //sets back the original interval which will start counting from its full value again
 
    stopTimer("timeLeftCounter");
    seconds = 60;
    updateMainLabel(true);
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 19 Dec 2013, 09:40 AM
Hello John,

You can set the KeepOnMouseOver property to false. It defaults to true, so when the mouse is over the notification it will stay opened. This is most likely the case when animations are enabled, because with them the control will not hide immediately, so a mouseover will fire after the click, which will return the control to its visible state. Thus, your other option is to disable animations, like in the demo.

Note that the first click is supposed to invoke the callback that will refresh the Session timer on the server, and you can monitor the network requests to confirm this.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Notification
Asked by
John
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Share this question
or