| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Is there some event I can monitor to tell either if a new li has been created as a child of a certain ul, or to tell if the ul contents have changed in general (so that I can walk the children looking for new items)? It's a sort of odd request, but I'm using a 3rd-party filebrowser library that uses Flash to implement a multiselect-capable file upload tool. The browser append children to a UL, but I'd also like to include a bit of metadata with each file that's being uploaded. I've got several workarounds in mind, but I'm curious as to the original question. If this is not the appropriate newsgroup for this kind of question, I apologize and please let me know if you have a suggestion for a better forum. Thanks for your time! |
|
#2
| |||
| |||
| sjdevnull@yahoo.com meinte: > Is there some event I can monitor to tell either if a new li has been > created as a child of a certain ul, or to tell if the ul contents have > changed in general (so that I can walk the children looking for new > items)? No. Gregor -- http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie http://web.gregorkofler.com ::: meine JS-Spielwiese http://www.image2d.com ::: Bildagentur für den alpinen Raum |
|
#3
| |||
| |||
| On Sep 8, 5:08*pm, Gregor Kofler <use...@gregorkofler.at> wrote: > sjdevn...@yahoo.com meinte: > > > Is there some event I can monitor to tell either if a new li has been > > created as a child of a certain ul, or to tell if the ul contents have > > changed in general (so that I can walk the children looking for new > > items)? > > No. Well, strictly, yes, there is *some* event. W3C DOM 3 Event interface includes DOMNodeInserted and DOMNodeInsertedIntoDocument, plus "removed" equivalents. However, not many browsers support that. <URL: http://www.w3.org/TR/DOM-Level-3-Eve...Types-complete > -- Rob |
|
#4
| |||
| |||
| RobG wrote: > On Sep 8, 5:08 pm, Gregor Kofler <use...@gregorkofler.at> wrote: >> sjdevn...@yahoo.com meinte: >>> Is there some event I can monitor to tell either if a new li has been >>> created as a child of a certain ul, or to tell if the ul contents have >>> changed in general (so that I can walk the children looking for new >>> items)? >> No. > > Well, strictly, yes, there is *some* event. > > W3C DOM 3 Event interface includes DOMNodeInserted and > DOMNodeInsertedIntoDocument, plus "removed" equivalents. However, not > many browsers support that. > > <URL: http://www.w3.org/TR/DOM-Level-3-Eve...Types-complete As a fallback, one can use self-issuing window.setTimeout() calls or one window.setInterval() call to watch for changes in the subtree regularly. The cross-browser reaction time cannot be smaller than 10 ms, then, and it is likely to be greater (because the system timer tick interval may be greater, other tasks/threads might interfere, and the test takes time, too). PointedEars -- Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.) -- from <http://www.vortex-webdesign.com/help/hidesource.htm> |
|
#5
| |||
| |||
| sjdevnull@yahoo.com a écrit : > Is there some event I can monitor to tell either if a new li has been > created as a child of a certain ul, or to tell if the ul contents have > changed in general (so that I can walk the children looking for new > items)? > > It's a sort of odd request, but I'm using a 3rd-party filebrowser > library that uses Flash to implement a multiselect-capable file upload > tool. The browser append children to a UL, but I'd also like to > include a bit of metadata with each file that's being uploaded. function includeDatas(ul_Id, mydatas) { var u = document.getElementsById(ul_id); if (u) { u = u.getElementsByTagName('LI'); if(u.length>0) { for(var i=0, n=u.length; i<n; i++) if(u[i].innerHTML != '') { var t = document.createElement('SPAN'); t.innerHTML = mydatas; u[i].appendChild(t); } } } } > I've got several workarounds in mind, but I'm curious as to the > original question. var doesItFlash = false; function flashInserted() { var u = document.getElementsByTagName('LI'); if(u.length>0) { for(var i=0, n=u.length; i<n; i++) if( u[i].innerHTML != '' && u[i].getElementsByTagName('OBJECT') && u[i].getElementsByTagName('OBJECT').length>0) { doesItFlash = true; } or : var C = { old: 0, recent: 0 }; function changedContent() { var d = document.getElementsByTagName('*'); if(C.old == 0) C.old = d.length; C.recent = d.length; if( C.old == C.recent ) return false; C.old = C.recent; return true; } window.onload = changedContent; test : alert('is there more elements ? '+changedContent()); -- sm |
|
#6
| |||
| |||
| RobG meinte: > Well, strictly, yes, there is *some* event. > > W3C DOM 3 Event interface includes DOMNodeInserted and > DOMNodeInsertedIntoDocument, plus "removed" equivalents. However, not > many browsers support that. > > <URL: http://www.w3.org/TR/DOM-Level-3-Eve...Types-complete Right. Unfortunately, well, won't work for approx. 80% of the visitors, though... Gregor -- http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie http://web.gregorkofler.com ::: meine JS-Spielwiese http://www.image2d.com ::: Bildagentur für den alpinen Raum |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.