除非单击,否则在引导模式下看不到Codemirror内容 [英] Codemirror content not visible in bootstrap modal until it is clicked

查看:145
本文介绍了除非单击,否则在引导模式下看不到Codemirror内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带引导程序的Codemirror 3。
在我的引导程序模式中,有一个textarea,我将其替换为codemirror。
我正在使用 task_name_editor.setValue(初始值)初始化带有输入的代码镜像。
问题是内容在那里,但是直到焦点被单击或按下任何键时它才可见。

I am using codemirror 3 with bootstrap. In my bootstrap modal, there is a textarea, and i am replacing it with codemirror. I am using task_name_editor.setValue('initial value') to initialise codemirror with an input. The problem is that the content is there, but it is not visible until it is clicked or any key is pressed while it is focused.

我尝试了Marijn's回答类似的问题,但我不知道在哪里放置 task_name_editor.refresh()

I tried Marijn's answer to a similar question, but i don't know where to place task_name_editor.refresh()

$('#edit_task_modal').modal('show');
task_name_editor.setValue('initial value');
task_name_editor.refresh();

即使那样,它也不起作用
请问有人可以显示如何解决此问题吗?

even then, it is not working Please can anyone show how to fix this problem ?

推荐答案

也许更清洁的解决方案?

A cleaner solution perhaps?

Bootstrap模态有一个事件在显示模态后触发在Bootstrap 3中,这是 shown.bs.modal

Bootstrap modals have an event that fires after the modal is shown. In Bootstrap 3, this is shown.bs.modal.

modal.on('shown.bs.modal', function() {
    // initialize codemirror here
});

这篇关于除非单击,否则在引导模式下看不到Codemirror内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆