TinyMCE-附加到通过AJAX调用加载的div [英] TinyMCE - attach to divs loaded via AJAX calls
问题描述
我知道之前已经有人问过这个问题,但是我正在尝试通过jQuery(AJAX)加载附加到tinymce实例的div.
I know this has been asked before, but I'm trying to load some divs via jQuery (AJAX) that are attached to a tinymce instance.
在AJAX加载的页面中,有几个由PHP循环创建的tinymce div;
In the page loaded by AJAX, there are several tinymce divs, that are created by a PHP loop;
<div id="editable_ID1"><p>Some text</p></div>
<div id="editable_ID2"><p>Some more text</p></div>
tinymce.init({
selector: "#editable_ID1",
..............
});
tinymce.init({
selector: "#editable_ID2",
..............
});
ID1
和ID2
是通过PHP循环从数据库中动态获取的.
ID1
and ID2
are dynamically taken from the database via the PHP loop.
我的问题是,我似乎无法加载tinymce并将其附加到这些div元素上.
My problem is, I cannot seem to load the tinymce and attach it to these div elements.
我看过:
tinyMCE.execCommand('mceAddControl', true, 'id');
但是,这似乎并没有将tinymce附加到元素上
But again, this doesn't seem to attach the tinymce to the elements
谢谢
jQuery(document).ready(function(){
jQuery(document).ready(function () {
var child = jQuery(this).attr('data-id');
$.ajax({
type: "POST",
url: '<?php echo url_for('@load_template_from_nav') ?>',
data: "template_id="+child,
success: function(data)
{
// replace ajax page content
$('.template-editor-item-replace').html(data);
tinyMCE.execCommand('mceAddControl', true, 'editable_1');
}
});
});
推荐答案
您将需要明确调用ID.使用
You will need to call the id explizitly. Use
tinyMCE.execCommand('mceAddControl', true, 'editable_ID1'); // additionaly editable_ID2
这篇关于TinyMCE-附加到通过AJAX调用加载的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!