Skip to content Skip to sidebar Skip to footer

Is It Possible To Stop Closing Jquery Modal Popup On Page Refreshing?

I am developing one MVC4 application where I am displaying some information on Modal popup. I am able to display the required information. If I refresh the page when the Modal is o

Solution 1:

Use localStorage() to set the current state of pop up.

function cancel(upload_Id)
{
    if (!$("#formID").validationEngine('validate')) {
         return false;
    }
    $("#id").val(upload_Id);
    $(".reject-popup-inner").parents('div').addClass('reject-popup');
    $("#dialog-form").dialog("open");
    //Set item in localStorage
    localStorage.setItem('popupFlag', 1);
}

On page load you can check the flag

$(document).ready(function(){
   //Get and Check item in localStorage
   if(localStorage.getItem('popupFlag') == 1)
   {
      $("#dialog-form").dialog("open");     
   }
});

Finally, you can remove the item from localStorage item

//Remove item from localStorage
localStorage.removeItem('popupFlag')

FYI, to use localStorage your browser should be HTML5 supported.

Reference

HTML5 Local Storage


Post a Comment for "Is It Possible To Stop Closing Jquery Modal Popup On Page Refreshing?"