CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   Only in IE, prototype's Element.update() doesn't work multiple times (http://www.codingforums.com/showthread.php?t=177280)

becked 09-17-2009 06:44 PM

Only in IE, prototype's Element.update() doesn't work multiple times
 
The following code works find in firefox and chrome. In IE, it only works the first time I click on a link. Any ideas?

Thanks in advance,

// I have some div's where help is, which I make non-viewable
<div id='help_guides'>
<div id='issue1'>Help with issue 1</div>
<div id='issue2'>Help with issue 2</div>
</div>
<a href="#" id="issue_1_link">Help with issue #1</a>
<a href="#" id="issue_2_link">Help with issue #2</a>
<div id='help'></div>

// I grab the help guide div into a variable
var issue_1_help = $('issue_1').remove();
var issue_2_help = $('issue_2').remove();

// When the help link is clicked, the help DIV displays the help guide
Event.observe( $('issue_1_link'), 'click', function() {
$('help').update( issue_1_help );
});
Event.observe( $('issue_2_link'), 'click', function() {
$('help').update( issue_2_help );
});

becked 09-17-2009 07:04 PM

Well, I believe the reason is that I am creating multiple elements with the same ID, causing IE confusion. Changing:
var issue_1_help = $('issue_1').remove();
to:
var issue_1_help = $('issue_1').remove().innerHTML;

seems to have resolved the issue.


All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.