Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda