문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top