我正在使用jQuery打开一个对话框窗口,其中textarea转换为CKEditor的实例.我正在使用CKEditor团队提供的jQuery适配器,但是当对话框窗口打开时,我无法与编辑器交互(它已创建,但“null”写在内容空间中,我无法点击任何内容或修改内容).
This bug report似乎说通过使用补丁提供问题是固定的,但它似乎并没有为我工作…
这是我的代码(也许我以编程方式做错了):
HTML:
- <div id="ad_div" title="Analyse documentaire">
- <textarea id="ad_content" name="ad_content"></textarea>
- </div>
- <script type="text/javascript" src="includes/ckeditor/ckeditor.js"></script>
- <link rel="stylesheet" type="text/css" href="includes/jquery/css/custom-theme/jquery-ui-1.7.2.custom.css" />
- <script type="text/javascript" src="includes/jquery/js/jquery-1.3.2.min.js"></script>
- <script type="text/javascript" src="includes/jquery/js/jquery-ui-1.7.2.custom.min.js"></script>
- <script type="text/javascript" src="includes/jquery/plugins/dialog-patch.js"></script>
- <script type="text/javascript" src="includes/ckeditor/adapters/jquery.js"></script>
使用Javascript:
- $('#ad_content').ckeditor();
- /* snip */
- $('#ad_div').dialog(
- {
- modal: true,resizable: false,draggable: false,position: ['center','center'],width: 600,height: 500,hide: 'slide',show: 'slide',cloSEOnEscape: true,autoOpen: false
- });
- $('.analyse_cell').click(function(){
- $('#ad_div').dialog('open');
- });
编辑:经过一些进一步的测试后,我注意到按下工具栏按钮给了我这个错误:
Error: this.document.getWindow().$is
undefined Source File:
includes/ckeditor/ckeditor.js Line: 82
解决方法
我使用带有“show:”选项的回调函数来延迟实例化CKEditor,直到“show”动画完成.我发现只需50毫秒即可.
- modal: true,show: {
- effect: "drop",complete: function() {
- setTimeout(function(){
- $( "#selector" ).ckeditor();
- },50);
- }
- },hide: "drop",
希望这可以帮助.