Borstenhorst
Borstenhorst

Reputation: 1786

How to hide/unhide codemirror

I want to hide/unhide a codemirror instance completely. Is there any predefined method doing that, or do I need to somehow select the div and make it hidden.

Upvotes: 5

Views: 5359

Answers (3)

Systemsplanet
Systemsplanet

Reputation: 419

This works

var cm = $('.CodeMirror')[0];
var cm$ = $(cm.getWrapperElement());
//Hide
cm$.hide();
//Show
cm$.show();

Upvotes: 0

GobSmack
GobSmack

Reputation: 2261

Building upon Lochemage's answer, the following code will perform hide/show of Codemirror instance.

var cm = $('.CodeMirror')[0].CodeMirror;

//Hide
$(cm.getWrapperElement()).hide();

//Show
$(cm.getWrapperElement()).show();

Upvotes: 7

Lochemage
Lochemage

Reputation: 3974

according to the documentation, CodeMirror's main editor object has a method that returns to you the main wrapper DOM element.

cm.getWrapperElement()

From there, you should be able to just hide the element like you would hide any html element.

Upvotes: 8

Related Questions