1

I am searching for an event which is raised when I add a new item to an UL-List. Is there something like that?

Thanks.

Igor
  • 31,955
  • 14
  • 75
  • 111
Thu marlo
  • 523
  • 2
  • 5
  • 10

3 Answers3

4

In short: no.

But you can trigger your own events in jQuery when you add those lis:

$('ul').bind('liAdded', function(){
    alert('An "li" was added!');
});

$('ul').append('<li>').trigger('liAdded');
Joseph Silber
  • 205,539
  • 55
  • 352
  • 286
1

You can try the following (haven't tested but seems promising): http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified

I'm not completely sure if its just a W3 standard thing or its actually put in use in modern browsers.

DOMAttrModified A user agent must dispatch this event after an Attr.value has been modified and after an Attr node has been added to or removed from an Element.

Shai Mishali
  • 8,156
  • 4
  • 50
  • 79
  • Sadly, mutation events have been deprecated and the support that do exist, is minimal at most. – mekwall Sep 20 '11 at 06:17
  • Wrong event but pretty close. The OP is looking for an event based on changes to the DOM, so a [DOM Mutation event](http://www.w3.org/TR/DOM-Level-3-Events/#events-mutationevents). The DOMAttrModified event is for modified attributes. But as Marcus says, it's deprecated and not widely implemented anyway. A simple solution is to manually call the "event" when modifying the DOM. – RobG Sep 20 '11 at 06:17
1

ie678 (CSS):

ul * {behavior: url(x.htc)}

and callback in x.htc:

<script type="text/javascript">
notify(this.element);
</script>

w3c standard:

document.addEventListener("DOMNodeInserted", function(e){...})