views:

531

answers:

2

This is killing me. In both IE7 and 8, using jqModal, the screen flashes black before the modal content is loaded. I've set up a test app to show you what's happening. I've taken jqModal EXACTLY from the site, no changes whatsoever, no external css that could be affecting my app. It works perfectly in every other browser (including IE6).

http://jqmtest.heroku.com/

So, first two links are ajax calls, second is straight up inline HTML. (I originally thought it was the ajax that was affecting it, but that doesn't seem to be the case, I then thought it was slow loading ajax, hence to two differen ajax links)

What's crazy is that the jqmodal site itself works perfectly in IE, no flashing of black, but I can't see what I'm doing wrong. Code is straight forward

html:

<body>
<div id="ajaxModal" class="jqmWindow"></div>
<div id="inlineModal" class="jqmWindow">
  <div style="height:300px;position:relative;">  
    <p>Here's some inline content</p>
    <a href="#" onclick='$("#inlineModal").jqmHide();return false;' style="position:absolute;bottom:10px;right:10px">Close</a>
  </div>
</div>
<div style="width:600px;height:400px;margin:auto;background:#eee;">
  <p><a href="/ajax/short" class="jqModal">Short loading modal</a></p>
  <br />
  <p><a href="/ajax/long" class="jqModal">Longer loading modal</a></p>
  <br />
  <p><a href="#" class="jqInline">inline modal</a></p>
</div>    
</body>

Javascript:

<script type="text/javascript">
  $(function(){
    $("#ajaxModal").jqm({ajax:'@href', modal:true});
    $("#inlineModal").jqm({modal:true, trigger:'.jqInline'});
  });
</script>

CSS is exactly the same as the one downloaded from jqModal's site so I'll omit it, but you can see it on my app

Has anyone experienced this? I don't get how his works and mine doesn't.

A: 

After playing around with the source, I found a workaround. Change line 41 (in jqModal r14) from:

if(c.modal) {if(!A[0])L('bind');A.push(s);}

to

if(c.modal) {A.push(s);}

I've also hosted the fix here along with a demo for IE7. I'm not entirely sure what that change does since the source is minified (though I'd guess it might have something to do showing multiple modals at once), so be sure to test it out fully to make sure it doesn't break anything.

jimyi
awesome, I'll test this when I get a chance. How friggin annoying is the source for jqModal! I don't get why anyone would purposefully write code like that (it's not technically minified, he just wrote it like that). Thx I'll be back with my findings
brad
A: 

I tried jimyi's solution, but it wasn't fixing the problem for me. So here's what I came up with:

In my CSS I've added a new rule

.jqmOverlay { display: none; }

and when I am popping up that particular modal dialog I do this:

$("#pleaseWait").jqmShow();   // show the modal dialog
$(".jqmOverlay").fadeIn(10);  // very quick fade-in

The fade-in works to override the CSS rule & the black flash is eliminated.

Note: I haven't tested it, but the fadeIn action might interfere with displaying a modal dialog where the overlay isn't completely transparent.

Steve Eisner