Bootstrap Modal Popup is Grayed Out

The popup shows up, but after it pops up the whole page becomes unusable.  So not only was it not displaying right, the whole page is frozen.  I found a StackOverflow post, below describing how the popup may have that behavior when it is nested inside elements that have positioning elements, which fits with previous experiences I have had.  One of the answers described how appending the modal popup to the body of the page  "$('#mytModal').appendTo('body');" would be a way of getting it out of any positioning elements.  Previously on a different page I had moved it out of some divs and it worked right.  However in this particular site the modal is in a ASP.Net site as a user control where the "offending" positioning element is in the master page and it contains the user control.  I stuck the script in the user control, but the behavior was the same.  When I used Firebug I saw that I was getting a "$ is not defined" message. With Jquery we need the Jquery reference defined before anything that uses it.  Viewed the master page and the Jquery reference was at the bottom so I moved it before anything else.  That fixed the issue, and now the modal shows right.

So in Summary:

1) Stuck this on the top of the user control to get it out of any elements that have positioning:

<script>
    $(function () {
        $('#myModal').appendTo('body');
    });

   </script>
2) Had to move my jquery reference before other scripts in the master page.

Refs
http://stackoverflow.com/questions/10636667/bootstrap-modal-appearing-under-background
http://stackoverflow.com/questions/2194992/jquery-is-not-defined




Comments

Popular posts from this blog

Asp.net Publishing Broke Site - "App_WebReferences is not allowed because the application is precompiled"

Telerik - Custom Group Footers In RadGrid