Created
June 16, 2011 16:36
-
-
Save vanm/1029643 to your computer and use it in GitHub Desktop.
Remove Associated Elements
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 | |
| var newComponent = new Component({ | |
| // Init creates domElement and associatedElements properties | |
| // Override removeElement method | |
| removeElement: function(){ | |
| this.domElement.remove(); | |
| $.each(this.associatedElements, function(){ | |
| $(this).remove(); | |
| }); | |
| this.domElement = null; | |
| this.associatedElements = []; | |
| } | |
| }); | |
| // Later in the application lifecycle you create a flashContainer | |
| // and want to ensure it's cleaned up alongside the newComponent.domElement | |
| newComponent.associatedElements.push(flashContainer); | |
| // removeElement destroys the domElement and flashContainer. | |
| newComponent.removeElement(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment