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.

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

On page load you can check the flag

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

Finally, you can remove the item from localStorage item

//Remove item from localStoragelocalStorage.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?"