Wow, if that sounded tragic it's due to some badass legacy script I'm
dealing with.
Before you tell me that I shouldn't be updating the document's body
like this, let me tell you that I completely agree with you.
Unfortunately this way of updating the page is part of a legacy ajax
implementation that I'm still fighting to get replaced (I could go on
and on about why I can't change that so please just trust me :) )
This is an IE-only site (blergh, I know) but the issue is interesting.
I was able to create a small repro:
(save this as repro.html and open in IE. IE8 is what I'm using)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>DP issue</title>
<link type="text/css" href="css/smoothness/jquery-ui-1.7.custom.css"
rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.custom.js"></
script>
</head>
<body>
<script>
var loadTime = new Date().toString();
function loadIframe(){
$('#myIFrame').attr('src', 'repro.html?d=' + (new
Date().getTime
()) );
}
function replaceBody(){
var html =
$('#myIFrame').contents().find('body').html();
$('body').empty().html( html );
// (1) ---- can't change code above this line ---
//tried with and without this next line, no diff.
stuffOnLoad();
}
</script>
Here's a datepicker <input type=text id="mydp" > <br>
<br>
Here's an iframe (it's not visible in the real app)<br>
<iframe id="myIFrame" width="500" height="50%" style="border:solid
2px red;"></iframe>
<hr>
Click each button in sequence (remember, only in IE)<br>
<input type="button" value="1 - Load IFRAME" onclick="loadIframe();" /
>
<input type="button" value="2 - Overwrite current body"
onclick="replaceBody();"/>
<script>
function stuffOnLoad(){
$('#mydp').datepicker({showOn: 'button', buttonImage:
'date.gif'});
}
$(stuffOnLoad);
</script>
</body>
</html>
When the page loads, the datepicker works. When I click the first
button, the datepicker inside the iframe also works. When I replace
the parent body with the iframe's body, then the datepicker that got
moved from the iframe to the main page stops working.
I know there's some reference mismatch or disposed objects doing some
damage here but I still couldn't figure out how to reactivate the
datepicker after the replacement.
If anyone could give me suggestions on what to put after the line
commented with //(1), I'd really appreciate. It may be something
trivial but I just couldn't see it.
Thanks a ton!
- sp
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---