Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
code mirror not initializing properly when not displayed

I have an editor page with three bootstrap tabs. In each of them I initialize a code editor in the same way eg:

code_element = document.getElementById('css');
code_element.value = message.css;
this.css_editor = CodeMirror.fromTextArea(code_element, {lineNumbers: false, mode:"text/css"});
this.css_editor.setSize("100%", "calc( 100vh - 350px )")

the one on the active tab works fine, but on the hidden tab... it ... works... but when you first change to the tab you just see nothing - clicking anywhere in the tab makes the editor appear, and from then on it works perfectly - you can tab away, back to it etc.

Any idea how I can fix that first time?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

so - more googling discovered that codemirror doesn't like initializing stuff if not displayed.

This code fixes things:

const $btn = "button[data-bs-target='#stylesheet_tab']";

$($btn).on('shown.bs.tab', () => saved_this.css_editor.refresh())
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda