Javascript 将文本添加到Froala文本编辑器
我试图通过编程将html输入到Froala文本编辑器中。根据他们的文件,这应该是可行的:Javascript 将文本添加到Froala文本编辑器,javascript,jquery,froala,Javascript,Jquery,Froala,我试图通过编程将html输入到Froala文本编辑器中。根据他们的文件,这应该是可行的: $(function(){ $('#editor').editable("setHTML", "<p>My custom paragraph.</p>", false); }); 。。。那么一切都好了 是否有人知道如何通过编程将html输入此编辑器。插入html后,请使用“同步” 两者都用。首先必须创建编辑器,然后才能设置HTML $(function(){ $('
$(function(){
$('#editor').editable("setHTML", "<p>My custom paragraph.</p>", false);
});
。。。那么一切都好了
是否有人知道如何通过编程将html输入此编辑器。插入html后,请使用“同步”
两者都用。首先必须创建编辑器,然后才能设置HTML
$(function(){
$('#editor').editable({inlineMode : false});
$('#editor').editable("setHTML", "<p>My custom paragraph.</p>", false);
});
$(函数(){
$('#editor')。可编辑({inlineMode:false});
$('#editor')。可编辑(“setHTML”,“我的自定义段落”,false);
});
您应该尝试以下方法:
$('#editor').froalaEditor('html.set', 'My custom paragraph.');
请参阅本参考资料中有关froala
方法的详细信息:
仅供参考。
在HTML中
对于正在查找v3答案的用户,您可以通过以下方式在v3中添加文本:
var editor = new FroalaEditor('.selector', {}, function () {
// Call the method inside the initialized event.
editor.html.insert('<p>My custom paragraph.</p>');
})
var editor=new FroalaEditor('.selector',{},函数(){
//在初始化事件内调用该方法。
insert(“我的自定义段落。”);
})
另外,如果要替换整个内容,则可以使用set方法
var editor = new FroalaEditor('.selector', {}, function () {
// Call the method inside the initialized event.
editor.html.set('<p>My custom paragraph.</p>');
})
var editor=new FroalaEditor('.selector',{},函数(){
//在初始化事件内调用该方法。
set(“我的自定义段落。”);
})
试试这个:
$('#editor').froalaEditor('html.set', 'My custom paragraph.');
$('#editor').froalaEditor('undo.saveStep', 'My custom paragraph.');
参考资料:对于最新版本的Froala,此功能运行良好
$("#froalaEditor")[0]["data-froala.editor"].html.set('This should work fine');
要附加文本,请使用
html.insert
$("#editor").froalaEditor('html.insert','<p>new text to append</p>');
$(“#编辑器”).froalaEditor('html.insert','要追加的新文本');
您找到解决方案了吗?您好,我已经找到了。在编辑表单时,当我提交表单时,此字段没有发布数据。如何发布此字段?谢谢你这对我有用。喜欢var通知_html=$(this.data('html')$(“textarea#feditor”).froalaEditor('html.set',notification_html);最后的方法是什么?
var editor = new FroalaEditor('.selector', {}, function () {
// Call the method inside the initialized event.
editor.html.set('<p>My custom paragraph.</p>');
})
$('#editor').froalaEditor('html.set', 'My custom paragraph.');
$('#editor').froalaEditor('undo.saveStep', 'My custom paragraph.');
$("#froalaEditor")[0]["data-froala.editor"].html.set('This should work fine');
$("#editor").froalaEditor('html.insert','<p>new text to append</p>');