aframe Entities Listening for Child Elements Being Attached and Detached


Example

We can use the child-attached and child-detached events to listen for when the scene attaches or detaches an entity:

entity.addEventListener('child-attached', function (evt) {
  if (evt.detail.el.tagName.toLowerCase() === 'a-box') {
    console.log('a box element has been attached');
  };
});