473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to tell when an li item is inserted into a ul?

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!
Sep 8 '08 #1
5 1048
sj*******@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
Sep 8 '08 #2
On Sep 8, 5:08*pm, Gregor Kofler <use...@gregorkofler.atwrote:
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
Sep 8 '08 #3
RobG wrote:
On Sep 8, 5:08 pm, Gregor Kofler <use...@gregorkofler.atwrote:
>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>
Sep 8 '08 #4
SAM
sj*******@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
Sep 8 '08 #5
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
Sep 8 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: none | last post by:
Hi. I'm implementing a web deployment using 9i. I have a table for STOCK, which has one or more PURCHASES, which have one or more PURCHASE_ITEMS. When a purchase item is INSERTED, I'd like the...
7
by: who be dat? | last post by:
I need some help here. I'm creating a list on a page where the list is created from a dataset with two tables linked with a datarelation. The first table is a list of groups while the second...
9
by: Don | last post by:
Is there any way to detect when an item has been added to the Items collection of a combobox or listbox? I am inheriting a Combobox and want to validate items before they are added to the...
2
by: dotnetnewbie | last post by:
Whilst looping through items in a listview I wish to have the option of inserting a new row (in the middle not necessarily at the end of the listview). thus if lvw is the listview name dim...
4
by: Peter Afonin | last post by:
Hello, I have a weirdest issue I've ever had. I have a function that enters some data into the Oracle table and returns the sequential row number for the new record (autonumber): Private...
4
by: Pucca | last post by:
How can I tell a mouse right clicks over a listview item that's in a container panel. I only want to display a popup menu if the user right click the mouse over an item on the Listview. I don't...
2
by: polocar | last post by:
Hello, I'm developing a C# program using Visual Studio 2005 Professional Edition. In the main form I have inserted a ListView control that is populated in a different way depending on the item...
2
by: Chris | last post by:
I have a custom exception which gets thrown in my business layer. I catch it in the item inserted event of my formview. How do I tell whether it is a custom error or another type of error. Is there...
8
by: AAaron123 | last post by:
If IE is open I'd like my app to receive an event or otherwise know when IE receives a mouse click. Is that fairly easy to do? Thanks in advance
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.