Created
June 14, 2011 21:30
-
-
Save vanm/1025944 to your computer and use it in GitHub Desktop.
Remove associated element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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