【发布时间】:2016-10-12 08:42:08
【问题描述】:
当我尝试设置包含“\n”的文本时。它显示错误 - Uncaught SyntaxError: Unexpected token ILLEGAL in browser console
在 java 脚本控制台中,我得到如下文本。
<script type="text/javascript">
var toolbarOptions = [
[{ 'font': [] }],
[{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
['bold', 'italic', 'underline', 'strike'], // toggled buttons
//['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }], // custom button values
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
//[{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript
[{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent
//[{ 'direction': 'rtl' }], // text direction
[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
[{ 'align': [] }],
['clean'] // remove formatting button
];
var quill = new Quill('#standalone-container', {
modules: {
toolbar: toolbarOptions
},
theme: 'snow'
});
var quill1 = new Quill('#standalone-container1', {
modules: {
toolbar: toolbarOptions
},
theme: 'snow'
});
$(".tacti_note_txt").click(function(){
$("#order_video_01").get(0).pause();
})
$(".tech_note_txt").click(function(){
$("#order_video_02").get(0).pause();
})
$(document).ready(function(){
// my element which display errors
var technical_notes = '<%= raw @review.technical_notes %>';
quill.setText(technical_notes);
var tactical_notes = '<%= @review.tactical_notes.to_s %>';
quill1.setText(tactical_notes);
});
</script>
我想在编辑器中显示如下文本:
'Rails
and
quill
editor
;
【问题讨论】:
-
请显示浏览器的
var technical_notes...行 -
\n符号可能会将该行分成多行。尝试使用``字符串而不是''字符串 -
@Dimava,我在这里遇到错误 -> var Technical_notes = '';
-
这里的问题是编辑器需要像 "uhgfjgfjvj\r\nghjghjghjhgj\r\nghj\r\nghj\r\nhg\r\njghj\r\n" 这样的文本。我的数据库也保存了相同的。但是在页面上显示它认为输入的文本而不是“\n”,这就是问题
标签: javascript ruby-on-rails ruby-on-rails-4 quill