我使用summernote wysiwyg编辑器,我需要插入引号。在文档中,我没有找到如何插入这样的东西的方法,我尝试了使用insertNode,但是它返回了Uncaught TypeError:无法读取未定义的属性'toUpperCase‘--就像我发现insertNode只对空document.createElement工作一样。
我也尝试过使用summernote(代码,引号),但它只是替换了内容。我甚至尝试创建新元素、添加类和添加内容,但仍然得到相同的toUpperCase错误。
这是我已经试过的东西。
function quote(post) {
var entry = $(post),
author = entry.find('.quotable-author').text(),
date = entry.find('.quotable-date').text(),
content = entry.find('.quotable-content').html(),
quote = '<blockquote class="quote">' + content + '<footer>' + author + ' - ' + date + '</footer></blockquote>';
$('.editor').summernote('insertNode', quote);
}在夏季笔记中可以这样做吗?还是我应该搜索另一个wysiwyg编辑器?
发布于 2016-02-16 12:17:22
insertNode使用第一个参数作为元素,而不是字符串。您可以轻松地使用jquery创建元素。
var quote = $('<blockquote class="quote">hello<footer>world</footer></blockquote>')[0];
$('.editor').summernote('insertNode', quote);http://summernote.org/deep-dive/#insertnode
https://stackoverflow.com/questions/35388424
复制相似问题