code: function() {
        var wasAttached;
        if (this.isAttachedToParent()) {
           wasAttached = this.isAttached();
          // Detach view from DOM
          this.trigger('before-dom-detach');
          if (this.injectionSite) {
            this.$el.replaceWith(this.injectionSite);
            this.injectionSite = undefined;
          } else {
            this.$el.detach();
          }
          if (wasAttached) {
            this.__invokeDetached();
          }
          this.undelegateEvents();
          this.__isAttachedToParent = false;
        }
      }
docs: If attached, will detach the view from the DOM.
  This method will only separate this view from the DOM it was attached to, but it WILL invoke the _detach
  callback on each tracked view recursively.
  @method detach