Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!