nyroModal popup - disable scrolling outside of modal popup

nyroModal popup - disable scrolling outside of modal popup

I don't know if I'm phrasing my question correctly. I'm using nyroModal modal popup. It works great except for the fact when I open content in modal box, and try to scroll outside the modal box, the web page behind it scrolls. I don't want the webpage to scroll when the modal is popped up. It is a default nyroModal behavior right now. Is there an easy way to modify this behavior?

As I inspected one other popup plugin out there, I found that I need to set overflow:hidden on html element, like so: <html style="overflow: hidden;">. This way the webpage scrolling stops when modal is triggered.

So, my question is, is it easy to add overflow:hidden to <html> element on nyroModal? Currently this is all the code that is required to trigger nyroModal

$(function() { $('.nyroModal').nyroModal(); showCloseButton: true });


I also found this gentelman who tried to solve this problem like so:

  
  1. <script type="text/javascript">
  2. $(function () {
  3. $("[data-gal^='nyromodal']").nm({
  4. callbacks: {
  5. beforeShowCont: function (nm) {
  6. $('body').css('overflow', 'hidden');
  7. }
  8. }
  9. });
  10. });
  11. </script>

He said it worked for him, but when I tried to implement his solution, it didn't work for me. I'm a newb at this stuff, perhaps that's the reason why it didn't work for me.

Your help is highly appreciated