我在rails应用程序中使用summernote文本编辑器。 当我在编辑器中输入纯文本时,我会在编辑器中输入的文本旁边获得html标记和其他字符。 我想知道如何在输出中得到纯文本。 我试过这个解决方案,我在网上找到,但我得到一个错误,说'var是一个保留字'
var plainText = $($("#summernote").summernote("code")).text()这是我咖啡文件中的summernote代码
$ -> $('[data-provider="summernote"]').each -> $(this).summernote height: 300I am using summernote text editor in a rails app. When I type in plain text in the editor, I get html tags and other characters alongside the text i typed in the editor. I would like to know how i can derive just plain text in the output. I tried this solution i found online but I get an error saying 'var is a reserved word'
var plainText = $($("#summernote").summernote("code")).text()This is the summernote code in my coffee file
$ -> $('[data-provider="summernote"]').each -> $(this).summernote height: 300最满意答案
我终于找到了这个问题的简单解决方案,它没有JavaScript。 在编辑器中键入或粘贴文本后,必须清理输出。 举例来说,在你的展示页面中,你就是这样做的
<%= sanitize @job.description %>然后你毫无麻烦地获得纯文本。 `
I finally found a simple solution to this problem and it is without JavaScript. After typing or pasting text into the editor, you have to sanitize the output. So for example, in your show page, you do
<%= sanitize @job.description %>Then you derive your plain text without any hassle. `
更多推荐
发布评论