2016-04-22 61 views
0

我有一个Summernote所见即所得的内容必须预先填充来自已从另一个Summernote实例提取的字符串中的内容。预填充Summernote与内容字符串Javascript

$("#summernote").summernote("code", 'This is thing's content from anither instance');

的问题时,有字符串中的引号字符,这将打破串的范围过早(在在单词事物的)发生。

是否有另一种方式我可以做到这一点?

已经到了我心中唯一的另一种方式是将其设置为加载文本编辑器功能之前删除“字符。

回答

2

逃生麻烦字符 '\',如:

$("#summernote").summernote("code", "This is thing\'s content from anither instance"); 

或者如果它预装有str_replace函数解析它:

$("#summernote").summernote("code", str_replace("'", "\\'", str));