Question

I have multiple instances of codemirror running on my page. Some are hidden and you can move between them using tabs. What I would like to do is be able to set the focus based on the container.

At some point the instance was initiated like this:

var cmInstance = CodeMirror(target, options());

So I would either like to be able to get the instance that was initiated on that container by using the container, something like:

cm = target.getCodeMirror();

or perhaps set the focus based on the container, something like:

target.setFocus();

Is anything like this possible or should I rather keep a record of individual instances in an array or something?

Was it helpful?

Solution

Okay so I opted to track my instances of codemirror in an array and address them based on an ID that I keep track of and link to the target. Once I have my instance I can just set focus using the codemirror method cmInstance.focus();

Currently I feel this is the best solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top