1

using standard routine to remove all children in element

while( el.lastChild ) el.removeChild( el.lastChild );

yields: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8

for( var i=el.children.length; i; i-- ) el.removeChild( el.children[i-1] );

yields same

routine works 99% of the time, but in one DIV errors out.

if it matters, focus is not in DIV.

any idea how to proceed?


Found problem.

On new code for INPUT type='number' where input and mouseout events created a change event so field would update correctly.

In some instances updating the item meant removing the row.

The problem was that, once the row was removed, the INPUT's focus was lost, thereby generating its own change event. When this event ran the row was still existent, but had lost the relationship to its parent. This generated the DOM Error 8 - not found.

Again, we have met the enemy, and they is us (thank you Pogo).

cc young
  • 18,939
  • 31
  • 90
  • 148
  • possible duplicate of [Remove all the children DOM elements in div](http://stackoverflow.com/questions/683366/remove-all-the-children-dom-elements-in-div) – Tomalak Sep 01 '11 at 07:26
  • 1
    This should work, so it would help if you could write which browser you are using and maybe provide a small example of HTML code you are using it on. – Wladimir Palant Sep 01 '11 at 07:32
  • @Tomalak - same algorithm, but nasty results – cc young Sep 01 '11 at 07:41
  • @Wladimir Palant - chrome. getting incompatibilities fixed for ff testing now. – cc young Sep 01 '11 at 07:44
  • I tried the bookmarklet `javascript:var el = document.body;while( el.lastChild ) el.removeChild( el.lastChild );void(0)` on a few websites in Chrome and it works fine. So it must be something related to your particular webpage. – Wladimir Palant Sep 01 '11 at 08:05
  • @Wladimir - I agree! this code has been working without problem for months. that it should suddenly fail to me is totally bizarre. Right now I'm eliminating HTML piece by piece to see if I can find one piece that breaks it. – cc young Sep 01 '11 at 09:00

1 Answers1

1

Problem was triggers attempting to remove the row once an earlier trigger had already removed it. See description at bottom of question

cc young
  • 18,939
  • 31
  • 90
  • 148