473,554 Members | 2,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1051
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...@gregork ofler.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
DOMNodeInserted IntoDocument, 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...@gregork ofler.atwrote:
>sjdevn...@yaho o.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
DOMNodeInserted IntoDocument, 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.setTimeo ut() calls or
one window.setInter val() 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.getEle mentsById(ul_id );
if (u) {
u = u.getElementsBy TagName('LI');
if(u.length>0) {
for(var i=0, n=u.length; i<n; i++)
if(u[i].innerHTML != '') {
var t = document.create Element('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.getEle mentsByTagName( 'LI');
if(u.length>0) {
for(var i=0, n=u.length; i<n; i++)
if( u[i].innerHTML != '' &&
u[i].getElementsByT agName('OBJECT' ) &&
u[i].getElementsByT agName('OBJECT' ).length>0) {
doesItFlash = true;
}
or :

var C = { old: 0, recent: 0 };
function changedContent( ) {
var d = document.getEle mentsByTagName( '*');
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 ? '+changedConten t());

--
sm
Sep 8 '08 #5
RobG meinte:
Well, strictly, yes, there is *some* event.

W3C DOM 3 Event interface includes DOMNodeInserted and
DOMNodeInserted IntoDocument, 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
2488
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 web module component to update the relevant grandparent record of STOCK, and when UPDATED, to remember the previous level and adjust accordingly. ...
7
2070
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 table is a list of items in that group. I want to show these items in what would basically look a lot like a tree view. I decided to just show...
9
7306
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 combobox, but I can't find anything that will let me do that. - Don
2
2463
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 itm as listviewitem For each itm in lvw.Items 'if certain condition is met then insert new row in the listview here
4
1375
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 Function AddSystem(ByVal txt As TextBox, ByVal cn As OracleConnection) As Integer Try
4
10777
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 not want to display this menu if a node selected on the listview but user right click over the empty space of the panel that contain the listview. ...
2
1738
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 selected in a ComboBox. I have written a procedure that reads the ComboBox selected item and populates the ListView according to that. The procedure...
2
1341
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 a way of saying is "e.exception of type custom error". Regards, Chris.
8
1311
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
7605
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7808
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8047
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7893
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6156
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5441
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3556
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2022
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.