removed

  • typedef
2.0

{Object}

 

The event object dispatched when an element is removed from the document.

Object

Properties

  1. target {HTMLElement}

    The attribute that changed.

  2. type="removed" {String}Optional

    The type is always "removed" for a removed event.

  3. bubbles=false {Boolean}Optional

    Removed events do not bubble.

Use

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

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

$(el).remove()

Listen to a removed event with can.Control like:

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

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

<div can-removed="destroyItem">...</div>

Listen to a removed event with can.Component's events object like:

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

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

For jQuery or Zepto, use $.fn.html, $.fn.remove, $.fn.empty, etc:

 $(el).remove();

For Mootools use Element::set

 $(el).destroy()

For Dojo, use dojo.destroy;

 dojo.destroy(el);

For YUI use remove like:

Y.NodeList(el).remove();