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?
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?
Share Improve this question asked Oct 17, 2013 at 14:04 JeffJenkJeffJenk 2,6653 gold badges23 silver badges29 bronze badges 1 |1 Answer
Reset to default 19Okay 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.
CodeMirror
to the container DOM node, pointing at the editor instance. – Marijn Commented Oct 22, 2013 at 13:46