我只是在做一个小网络服务。因此,我正在使用 AJAX 调用并将我的数据附加到我网站上的表格中。在这里,我可以读取和更新现有条目或写入新条目。一切正常。
我希望有可能使用 wysihtml5 编辑器更新已经存在的内容。我已经在我的网站上集成了这个编辑器,我可以在新条目上使用它。这也有效。
但现在现有数据存在问题。当涉及到更新数据的表单时,我希望将现有数据显示为值。在所有输入上一切正常,只是 wysihtml5 不起作用。
我已经知道有一个 iframe,这就是为什么我不能设置 textarea 的值。我搜索了一个解决方案并找到了以下代码(最后一行):
var editor = new wysihtml5.Editor("textareaid", { // id of textarea element
toolbar: "wysihtml5-toolbar", // id of toolbar element
parserRules: wysihtml5ParserRules, // defined in parser rules set
});
editor.setValue('Here's the content', true);
通常这应该可以工作,但没有内容出现,控制台只是告诉我:
错误:wysihtml5.Sandbox:沙盒 iframe 尚未加载
我用超时功能尝试过,但没有任何效果。在互联网上搜索似乎也没有其他人有这个问题。我希望你能帮助我,那就太好了!
有没有办法设置值?
最佳答案
这段代码对我有用
$("#product_details").data("wysihtml5").editor.getValue();// to get the value
$("#product_details").data("wysihtml5").editor.setValue('new content')// to set the value
关于ajax - wysihtml5 - 设置值不起作用,因为 'sandbox iframe isn' 还没有加载',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18328216/