inserted

  • typedef
2.0

{Object}

 

The event object dispatched when an element is inserted into the document.

Object

Properties

  1. target {HTMLElement}

    The attribute that changed.

  2. type="inserted" {String}Optional

    The type is always "inserted" for an inserted event.

  3. bubbles=false {Boolean}Optional

    Inserted events do not bubble.

Use

Listen to an inserted event on an element with the base-library's NodeList. For example, with jQuery:

$(el).bind("inserted", function(ev){
  ev.type // "inserted"
  ev.target // el
})

$(parent).append(el);

Listen to an inserted event with can.Control like:

can.Control.extend({
  "inserted": function(el, ev){
  
  }
})

Call a method when an element is inserted within a template like:

<div can-inserted="addItem">...</div>

Listen to an inserted event with can.Component's events object like:

can.Component.extend({
  tag: "panel",
  events:{
    "inserted": function(el, ev){
    
    }
})

To create an inserted event, you must use the base-library NodeList's DOM modifier methods.

For jQuery or Zepto, use $.fn.html, $.fn.append, $.fn.after, etc:

 $(parent).html(el);

For Mootools use Element::grab:

 $(parent).grab(el)

For Dojo, use dojo.place;

 dojo.place(el,parent,"last");

For YUI, use anything that calls Y.DOM.addHTML append:

Y.one("div.parent").append(el);