Hi *, We don''t know if you guys are the right audience, but we got a problem with prototype.js we need to solve. Essentially, it is a compatibility bug with the IE. We wrote a component so it updates itself periodically using AJAX. we used the prototype.js to accomplish this (using the periodicalUpdater object). now the component works fine using firefox or opera, but NOT with IE. the problem is the following line of code: receiver.innerHTML = response; where receiver is of type: ''HTMLTableSectionElement'' (inheriting the innerHTML attribute from HTMLElement, which is a plain string) and response is of type string. the funny thing is: IE can read this attribute, but it cannot set it!!!! We were wondering if you ever used the periodicalUpdater and whether you experienced similar problems for we don''t know what we can still do, as it is vital for our component to replace this innerHTML string. regards, Martin, J?rg, Thomas
Try using response.responseText unless you are already setting that. Can you show us more of your code? Thanks, Jon Whitcraft Web Application Developer Online Services - Indianapolis Motor Speedway (317) 492-8623 -----Original Message----- From: rails-spinoffs-bounces@lists.rubyonrails.org [mailto:rails-spinoffs-bounces@lists.rubyonrails.org] On Behalf Of Martin Marinschek Sent: Tuesday, September 27, 2005 8:02 AM To: rails-spinoffs@lists.rubyonrails.org Subject: [Rails-spinoffs] prototype.js Hi *, We don''t know if you guys are the right audience, but we got a problem with prototype.js we need to solve. Essentially, it is a compatibility bug with the IE. We wrote a component so it updates itself periodically using AJAX. we used the prototype.js to accomplish this (using the periodicalUpdater object). now the component works fine using firefox or opera, but NOT with IE. the problem is the following line of code: receiver.innerHTML = response; where receiver is of type: ''HTMLTableSectionElement'' (inheriting the innerHTML attribute from HTMLElement, which is a plain string) and response is of type string. the funny thing is: IE can read this attribute, but it cannot set it!!!! We were wondering if you ever used the periodicalUpdater and whether you experienced similar problems for we don''t know what we can still do, as it is vital for our component to replace this innerHTML string. regards, Martin, J?rg, Thomas _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs ******************** ******************** This E-mail (and attachments) may contain confidential/privileged information intended only for the named addressee(s). Confidential health information is protected by federal and state law, including HIPAA. If you are not an intended recipient, you may not read, copy, disseminate or take any action in reliance on the content of this E-mail. Please notify the sender by reply E-mail and immediately and permanently erase this E-mail from your system. Your assistance is appreciated. E-mail transmission may not be secure or error-free. Information may be delayed, intercepted, corrupted, lost or destroyed. The company does not accept any liability for errors/omissions in the content of this E-mail (or attachments) that may arise as a result of electronic transmission. The company is not responsible for any loss/damage arising from any virus transmitted by this E-mail (or attachments). ******************** ********************
* Martin Marinschek <martin.marinschek@gmail.com> [2005-09-27 09:03]:> Hi *, > > We don''t know if you guys are the right audience, but we got a problem > with prototype.js we need to solve. > > Essentially, it is a compatibility bug with the IE. > > We wrote a component so it updates itself periodically using AJAX. we used the > prototype.js to accomplish this (using the periodicalUpdater object). > now the component works fine using firefox or opera, but NOT with IE. > the problem is the following line of code: > > receiver.innerHTML = response; > > where receiver is of type: ''HTMLTableSectionElement'' (inheriting the > innerHTML attribute from HTMLElement, which is a plain string) and > response is of type string. the funny thing is: IE can read this > attribute, but it cannot set it!!!! We were wondering if you ever used > the periodicalUpdater and whether you experienced similar problems for we > don''t know what we can still do, as it is vital for our component to > replace this innerHTML string.Martin Somwhere in the recesses of my memory is a voice saying that innerHTML on table related elements in IE is tricky. It''s also saying that you can still insert nodes constructed via the DOM. So, it gets chatty and suggests returning the table related element as a string of HTML, wrapped in a table element, giving it it''s full context, and inserting the full table into a DIV that has style.display = ''none''. Then you''d use the DOM methods (firstChild, nextSibling, removeChild, insertBefore) to detach the constructed table related element from the hidden table, and insert into the visible table. Now it stopped. It''s last words were "Rosebud". -- Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/index.html - http://engrm.com/blogometer/rss.2.0.xml
In any case - this is the sourcecode we are currently using... regards, Martin Ajax.Updater.prototype.extend(Ajax.Request.prototype).extend({ initialize: function(container, url, options) { this.containers = { success: container.success ? $(container.success) : $(container), failure: container.failure ? $(container.failure) : (container.success ? null : $(container)) } this.transport = Ajax.getTransport(); this.setOptions(options); var onComplete = this.options.onComplete || Prototype.emptyFunction; this.options.onComplete = (function() { this.updateContent(); onComplete(this.transport); }).bind(this); this.request(url); }, updateContent: function() { var receiver = this.responseIsSuccess() ? this.containers.success : this.containers.failure; var match = new RegExp(Ajax.Updater.ScriptFragment, ''img''); var response = this.transport.responseText.replace(match, ''''); var scripts = this.transport.responseText.match(match); if (receiver) { if (this.options.insertion) { new this.options.insertion(receiver, response); } else { receiver.innerHTML = response; } } if (this.responseIsSuccess()) { if (this.onComplete) setTimeout((function() {this.onComplete( this.transport)}).bind(this), 10); } if (this.options.evalScripts && scripts) { match = new RegExp(Ajax.Updater.ScriptFragment, ''im''); setTimeout((function() { for (var i = 0; i < scripts.length; i++) eval(scripts[i].match(match)[1]); }).bind(this), 10); } } }); On 9/28/05, Alan Gutierrez <alan-rails-spinoffs@engrm.com> wrote:> * Martin Marinschek <martin.marinschek@gmail.com> [2005-09-27 09:03]: > > Hi *, > > > > We don''t know if you guys are the right audience, but we got a problem > > with prototype.js we need to solve. > > > > Essentially, it is a compatibility bug with the IE. > > > > We wrote a component so it updates itself periodically using AJAX. we used the > > prototype.js to accomplish this (using the periodicalUpdater object). > > now the component works fine using firefox or opera, but NOT with IE. > > the problem is the following line of code: > > > > receiver.innerHTML = response; > > > > where receiver is of type: ''HTMLTableSectionElement'' (inheriting the > > innerHTML attribute from HTMLElement, which is a plain string) and > > response is of type string. the funny thing is: IE can read this > > attribute, but it cannot set it!!!! We were wondering if you ever used > > the periodicalUpdater and whether you experienced similar problems for we > > don''t know what we can still do, as it is vital for our component to > > replace this innerHTML string. > > Martin > > Somwhere in the recesses of my memory is a voice saying that > innerHTML on table related elements in IE is tricky. > > It''s also saying that you can still insert nodes constructed via > the DOM. > > So, it gets chatty and suggests returning the table related > element as a string of HTML, wrapped in a table element, giving > it it''s full context, and inserting the full table into a DIV > that has style.display = ''none''. Then you''d use the DOM methods > (firstChild, nextSibling, removeChild, insertBefore) to detach > the constructed table related element from the hidden table, and > insert into the visible table. > > Now it stopped. It''s last words were "Rosebud". > > -- > Alan Gutierrez - alan@engrm.com > - http://engrm.com/blogometer/index.html > - http://engrm.com/blogometer/rss.2.0.xml > >-- http://www.irian.at Your JSF powerhouse - JSF Trainings in English and German
* Martin Marinschek <martin.marinschek@gmail.com> [2005-09-28 03:11]:> In any case - this is the sourcecode we are currently using...[snip] Found this. Looked like it covered some points. http://www.codingforums.com/archive/index.php/t-17321.html Not that difficult to implement, my suggestion. Something like... var hiddenDiv = $(''HiddenDiv''); hiddenDiv.innerHTML = ''<table>'' + ''<tbody><tr><td>Hello, World</tr></td></tbody>'' + ''</table>''; // Path is... // div .table .tbody .tr var newRow = hiddenDiv.firstChild.firstChild.firstChild; newRow.parentNode.removeChild(newRow); var toBodyForReal = $(''TBodyOfRealTable''); toBodyForReal.insertBefore(newRow, toBodyForReal.firstChild); Make sure you put tbody in your markup, otherwise you''ll forget that it''s there when Internet Explorer inserts it for you. YMMV. Try it in static HTML first, so I don''t waste your time. It''s been years since I''ve delt with JavaScript, but I think that I hit this before. -- Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/index.html - http://engrm.com/blogometer/rss.2.0.xml
The current prototype.js 1.4.0_pre7 beta has following code, btw: Abstract.Insertion.prototype = { initialize: function(element, content) { this.element = $(element); this.content = content; if (this.adjacency && this.element.insertAdjacentHTML) { try { this.element.insertAdjacentHTML(this.adjacency, this.content); } catch (e) { if (this.element.tagName.toLowerCase() == ''tbody'') { this.fragment = this.contentFromAnonymousTable(); this.insertContent(); } else { throw e; } } } else { this.range = this.element.ownerDocument.createRange(); if (this.initializeRange) this.initializeRange(); this.fragment = this.range.createContextualFragment (this.content); this.insertContent(); } }, contentFromAnonymousTable: function() { var div = document.createElement(''div''); div.innerHTML = ''<table><tbody>'' + this.content + ''</tbody></ table>''; return div.childNodes[0].childNodes[0].childNodes[0]; } } Am 27.09.2005 um 15:02 schrieb Martin Marinschek:> Hi *, > > We don''t know if you guys are the right audience, but we got a problem > with prototype.js we need to solve. > > Essentially, it is a compatibility bug with the IE. > > We wrote a component so it updates itself periodically using AJAX. > we used the > prototype.js to accomplish this (using the periodicalUpdater object). > now the component works fine using firefox or opera, but NOT with IE. > the problem is the following line of code: > > receiver.innerHTML = response; > > where receiver is of type: ''HTMLTableSectionElement'' (inheriting the > innerHTML attribute from HTMLElement, which is a plain string) and > response is of type string. the funny thing is: IE can read this > attribute, but it cannot set it!!!! We were wondering if you ever used > the periodicalUpdater and whether you experienced similar problems > for we > don''t know what we can still do, as it is vital for our component to > replace this innerHTML string. > > > regards, > > Martin, J?rg, Thomas > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Thanks for the feedback! Now this should be more than everything we need ;) regards, Martin On 9/28/05, Thomas Fuchs <thomas@fesch.at> wrote:> The current prototype.js 1.4.0_pre7 beta has following code, btw: > > Abstract.Insertion.prototype = { > initialize: function(element, content) { > this.element = $(element); > this.content = content; > > if (this.adjacency && this.element.insertAdjacentHTML) { > try { > this.element.insertAdjacentHTML(this.adjacency, this.content); > } catch (e) { > if (this.element.tagName.toLowerCase() == ''tbody'') { > this.fragment = this.contentFromAnonymousTable(); > this.insertContent(); > } else { > throw e; > } > } > } else { > this.range = this.element.ownerDocument.createRange(); > if (this.initializeRange) this.initializeRange(); > this.fragment = this.range.createContextualFragment > (this.content); > this.insertContent(); > } > }, > > contentFromAnonymousTable: function() { > var div = document.createElement(''div''); > div.innerHTML = ''<table><tbody>'' + this.content + ''</tbody></ > table>''; > return div.childNodes[0].childNodes[0].childNodes[0]; > } > } > > > > Am 27.09.2005 um 15:02 schrieb Martin Marinschek: > > > Hi *, > > > > We don''t know if you guys are the right audience, but we got a problem > > with prototype.js we need to solve. > > > > Essentially, it is a compatibility bug with the IE. > > > > We wrote a component so it updates itself periodically using AJAX. > > we used the > > prototype.js to accomplish this (using the periodicalUpdater object). > > now the component works fine using firefox or opera, but NOT with IE. > > the problem is the following line of code: > > > > receiver.innerHTML = response; > > > > where receiver is of type: ''HTMLTableSectionElement'' (inheriting the > > innerHTML attribute from HTMLElement, which is a plain string) and > > response is of type string. the funny thing is: IE can read this > > attribute, but it cannot set it!!!! We were wondering if you ever used > > the periodicalUpdater and whether you experienced similar problems > > for we > > don''t know what we can still do, as it is vital for our component to > > replace this innerHTML string. > > > > > > regards, > > > > Martin, J?rg, Thomas > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >-- http://www.irian.at Your JSF powerhouse - JSF Trainings in English and German
* Thomas Fuchs <thomas@fesch.at> [2005-09-28 10:51]:> The current prototype.js 1.4.0_pre7 beta has following code, btw: > > Abstract.Insertion.prototype = { > initialize: function(element, content) { > this.element = $(element); > this.content = content; > > if (this.adjacency && this.element.insertAdjacentHTML) { > try { > this.element.insertAdjacentHTML(this.adjacency, this.content); > } catch (e) { > if (this.element.tagName.toLowerCase() == ''tbody'') { > this.fragment = this.contentFromAnonymousTable(); > this.insertContent(); > } else { > throw e; > } > } > } else { > this.range = this.element.ownerDocument.createRange(); > if (this.initializeRange) this.initializeRange(); > this.fragment = this.range.createContextualFragment > (this.content); > this.insertContent(); > } > }, > > contentFromAnonymousTable: function() { > var div = document.createElement(''div''); > div.innerHTML = ''<table><tbody>'' + this.content + ''</tbody></ > table>''; > return div.childNodes[0].childNodes[0].childNodes[0]; > } > }Wow! You thought of everything. -- Alan Gutierrez - alan@engrm.com - http://engrm.com/blogometer/index.html - http://engrm.com/blogometer/rss.2.0.xml
Sam did. :) Thomas Am 28.09.2005 um 17:17 schrieb Alan Gutierrez:> Wow! You thought of everything. > > -- > Alan Gutierrez - alan@engrm.com > - http://engrm.com/blogometer/index.html > - http://engrm.com/blogometer/rss.2.0.xml > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >