             this.domObject = $("#" + this.outerId)
         else
             this.domObject = $(this.outerTag + " ." + this.outerClass)
-        
+            
+            if this.domObject.length == 0
+                # Create object but don't add it yet. Parent will have to add it
+                # to the DOM at the right time.
+                this.domObject = $("<" + this.outerTag + ">", {class: this.outerClass})
+                
         this.delegateEvents()
         this.hide() if this.hideOnStart
+    
+    destroy: () ->
+        this.model = null
+        this.domObject.remove()
         
     show: () ->
         this.domObject.show()

            if this._model?
                this._model.registerEvent("change", this.render)
                this.render()
    })

class SimpleMVC.Controller extends SimpleMVC.Event
    this.prototype.baseUrl = "/"
     

    
    each: (fn) ->
        fn.call(this, i) for i in this._coll
    
    at: (i) ->
        this._coll[i]
    
    replace: (i, v) ->
        this.removeAt i
        this.insert v, i
        
class SimpleMVC.View extends SimpleMVC.Event
    # Default properties
    hideOnStart: false
