How to apply CodeMirror in Bootstrap Modal 1

How to apply CodeMirror in Bootstrap Modal

var myCodeMirror = CodeMirror(document.querySelector('.codemirror-init'), {
  value: 'Your Value',
  lineNumbers: true,
  tabSize: 2,
  mode: 'javascript',
  theme: 'monokai'
});

$('#exampleModal').on('shown.bs.modal', function() {
    // Refresh Code mirror Here
       myCodeMirror.refresh();
});

Here is what the above code is Doing:
1. We are creating a new CodeMirror instance and passing it the element we want to attach it to, and the options we want to use.
2. We are listening for the modal to be shown, and then refreshing the CodeMirror instance.

Similar Posts