# Adding and removing a ProseMirror instace on demand

**URL:** https://discuss.prosemirror.net/t/adding-and-removing-a-prosemirror-instace-on-demand/123
**Category:** Uncategorized
**Created:** [January 10, 2016, 12:05pm UTC](https://discuss.prosemirror.net/t/adding-and-removing-a-prosemirror-instace-on-demand/123 "2016-01-10T12:05:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![salzhrani](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@salzhrani](https://discuss.prosemirror.net/u/salzhrani)
#### Post date: [January 10, 2016, 12:05pm UTC](https://discuss.prosemirror.net/t/adding-and-removing-a-prosemirror-instace-on-demand/123/1 "2016-01-10T12:05:55Z")

</div>

Hello, In a long lived JS app, one might need to destroy a ProseMirror instance expecting all listeners and references to cleared. Is this currently possible? Also, is it possible to disable an instance ( Making it appear to be not editable ) and re enable it?

Thanks

---

<div class="post-metadata">

### Author: ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)
#### Post date: [January 11, 2016, 9:09am UTC](https://discuss.prosemirror.net/t/adding-and-removing-a-prosemirror-instace-on-demand/123/2 "2016-01-11T09:09:18Z")

</div>

You can just remove it from the DOM, that’s all it takes. There are no events registered on any nodes outside of the editor.

There is no support for making a ProseMirror instance non-editable. You could just replace it with the rendered form of the document (and maybe wrap it in a `.ProseMirror-content` element if you want the editor styles to apply), but that’s all I have for now.

---

<div class="post-metadata">

### Author: ![peteb](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/peteb/32/155_2.png) [@peteb](https://discuss.prosemirror.net/u/peteb)
#### Post date: [January 12, 2016, 9:01pm UTC](https://discuss.prosemirror.net/t/adding-and-removing-a-prosemirror-instace-on-demand/123/3 "2016-01-12T21:01:17Z")

</div>

I thought that maybe `pm.content.contenteditable = false` might work but it doesn’t seem to accept it (not sure why). However I commented out the `pm.content.contenteditable = true` and it was no longer editable. Marijn may know if there are other things to consider.

---

<div class="post-metadata">

### Author: ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)
#### Post date: [January 12, 2016, 10:09pm UTC](https://discuss.prosemirror.net/t/adding-and-removing-a-prosemirror-instace-on-demand/123/4 "2016-01-12T22:09:51Z")

</div>

A bunch of event handlers will also cause trouble, allowing you to still edit the document (by dragging, for example) or simply break (the selection-handling, which assumes the content is actually focusable).
