Codemirror does not display first in a modal

Asked

Viewed 35 times

1

Guys I am creating a standard model for reading XML and to facilitate the life of the system users, I am displaying a default model example in a modal with codemirror, however, it does not display at first, the code is only displayed when I click on the area of codemirror.

Modal de exibição do XML, ao clicar no centro o codemirror funciona

Method js codemirror

//codemirror
var editor_two = CodeMirror.fromTextArea(document.getElementById("code2"), {
        lineNumbers: true,
        matchBrackets: true,
        styleActiveLine: true,
        mode: "xml",
        htmlMode: true,
    });
    //fim 

Modal method

   //exibe modal de xml padrao
    $(".btnPadraoXml").on("click", function () {
       //exibe modal
       $("#myModalVisualizaModeloXMl").modal();             
        //tentativas sem sucesso
        editor_two.focus();
        //editor_two.on('shown');    

    })

1 answer

0


Follows code below:

    //exibe modal de xml padrao
    $(".btnPadraoXml").on("click", function () {   
        $("#myModalVisualizaModeloXMl").modal();             
        //resolvido
        setTimeout(function() {            
            editor_two.refresh()
        }, 2000);
    })

Browser other questions tagged

You are not signed in. Login or sign up in order to post.