Skip to content

Instantly share code, notes, and snippets.

@vanm
Created June 14, 2011 21:30
Show Gist options
  • Select an option

  • Save vanm/1025944 to your computer and use it in GitHub Desktop.

Select an option

Save vanm/1025944 to your computer and use it in GitHub Desktop.
Remove associated element
// Instantiate a Component (overriding removeElement method)
var newComponent = new Component({
removeElement: function(){
this.domElement.remove();
this.trigger('removeElement');
}
});
// Later in the application lifecycle you add a flashContainer
// and want to ensure it's cleaned up alongside the newComponent.domElement
newComponent.bind('removeElement', function(){
var component = this;
// Remove the associated Flash container if one exists
if (component.associatedElements.flashContainer){
component.associatedElements.flashContainer.remove();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment