jQuery: Disable backgroud scrolling when simplemodal modal box is opened.

When using jQuery simplemodal, when the modal box is box is opened , following is one way to disable the scrolling in the background.

We change the css overflow property of the background in the onShow and onClose functions..

Example:

$("#sample").modal({  
      maxWidth:800, minHeight:800,  
       onShow: function(dialog) {  
                 $("html,body").css("overflow","hidden");  
                 //YOur remaining javascript...  
            },  
       onClose: function(dialog) {  
                 $("html,body").css("overflow","auto");  
                 $.modal.close();  
            }  
 }); 

No comments:

Post a Comment

Python contextlib for Timing Python code

If you've ever found yourself needing to measure the execution time of specific portions of your Python code, the `contextlib` module o...