我正忙于一个具有主页的项目,该主页上有一个选项卡,每次我单击选项卡时,它都会将页面加载到包含 ID 内容的 div 标签中。
我正在加载到 div 标签中的页面之一包含一个文本区域,我需要在其中运行 TinyMCE。
我使用 JQuery 按以下方式将页面加载到 div 中
$('#content').load('step4.php');
有趣的是,当我在浏览器窗口中打开step4.php而不使用JQuery时,TinyMCE可以工作,一旦我通过load jquery方法加载它,它就不起作用,我只能看到文本框。
在顶部操作 step4.php 我有以下代码。
<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
theme : "advanced",
mode : "textareas",
plugins : "fullpage",
theme_advanced_buttons3_add : "fullpage"
});
</script>
最佳答案
这种情况发生在所有浏览器中还是仅发生在 Safari 中? (参见jQuery .load() call doesn't execute javascript in loaded html file)
也许是时间问题(init 在 js 文件加载完成之前运行) 您可以尝试在 $.load 回调中运行 init,例如
$('#content').load('step4.php', function() {
tinyMCE.init({
theme : "advanced",
mode : "textareas",
plugins : "fullpage",
theme_advanced_buttons3_add : "fullpage"
});
});
关于jquery - 使用 JQuery 时 TinyMCE 未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2177179/