Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-15-2008, 07:45 PM   PM User | #1
edislasm
New to the CF scene

 
Join Date: Nov 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
edislasm is an unknown quantity at this point
Exclamation PROTOTYPE Strange element.update() behavior

Hi everyone. I need to specify the innerHTML of an element but I've been having strange problems using innerHTML as well as Prototype's .update() function. Let's say I have this code:

alert(defaultcontent); //show the string of defaultcontent variable.
someelement.update(defaultcontent); //applies it to the element
alert(someelement.innerHTML); //shows the resulting content of the element

I've tried with several defaultcontent strings. With all of them the msg boxes show the same string as expected. This does well with both methods innerHTML and Prototype's update function. And it works in both IE and FF.

But I have a special string that brings me problems:

defaultcontent = '<TR><TH>City</TH><TH>State</TH></TR>';

I always get the first alert box with the string. But the second time it comes changed. Meaning that something happened when applying the HTML string to the element. The results I'm getting are:

in FF using innerHTML:
'CityState'

in FF using Prototype's update:
'CityState'

in IE using innerHTML:
'City</TH><TH>State</TH></TR>'
+Unknown runtime error.

in IE using Prototype's update:
Error. Object does not support this property or method.

IE with innerHTML is getting closer to the expected result, but the runtime error is something unbearable. But it sounds strange to me that in FF, both methods remove all HTML tags.

What could be wrong??
edislasm is offline   Reply With Quote
Old 11-15-2008, 07:56 PM   PM User | #2
edislasm
New to the CF scene

 
Join Date: Nov 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
edislasm is an unknown quantity at this point
Up to now, I have found a solution that works in FF and IE. The solution is using the BetterInnerHTML function by Craig Buckler from Optimal Works.

The thing is working fine. But I don't see why I have to add more libraries if I'm using already Prototype Framework. Well, congratulations for Craig Buckler.
edislasm is offline   Reply With Quote
Old 11-16-2008, 11:01 AM   PM User | #3
sybil6
Regular Coder

 
Join Date: Jul 2006
Posts: 399
Thanks: 33
Thanked 7 Times in 7 Posts
sybil6 can only hope to improve
ths solutions might also be not to use a framework, what you are trying to do is extremely simple.with plain javascript you would have your piece of code hence "you would know what you have" with prototype or other library you have an abstraction layer of one hundreds or more lines to start your search for debugging a two line code.
sybil6 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:11 AM.


Advertisement
Log in to turn off these ads.