-1
我正在寻找一种方法将quill.js集成到我的站点中,但他们提供的支持不存在或清除为泥浆。有人能帮我吗?quill.js与laravel 5.3论坛站点的集成
下面是我的代码,所有目前内联,以便更容易看到的一切。我已经设法让羽毛笔在页面上运行,并且我可以用它编辑文本,但是当我提交表单时,它不会提交编辑器的值,因为它应该是...
编辑器应该传递它的内容到一个隐藏的输入并提交它的内容,但是当我提交表单的输入不填充。
如果有人知道我做错了什么,那么我全都是耳朵,如果有人有更好的方法来尝试这个问题,那么我再次建议(顺便说一句,表单目前设置为GET,所以我可以轻松地检查什么被通过,但已经写控制器处理的变量是POST-ED。
<div class="row" style="margin-right: 0px; margin-left: 0px;">
<div class="col-md-6 col-md-offset-3">
<!-- Title and First Post -->
<div class="jumbotron">
<form method="get" action="/forum/create_post" id="create_post">
@if (count($errors))
<div style="padding: 10px;">
<div class="container-fluid" style="background-color: white; padding: 10px;">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
</div>
@endif
{{ csrf_field() }}
<div style="padding: 10px;">
<div class="container-fluid" style="background-color: white; padding: 10px;">
<input name="title" type="hidden">
<div id="editor-title">{{ old('title') }}</div>
</div>
</div>
<!--<h1><label for="Title">Title</label></h1>
<input class="form-control" name="title" type="text" placeholder="Your Title Here...">
<h1><label for="body">Content</label></h1>-->
<div style="padding: 10px;">
<div class="container-fluid" style="background-color: white; padding: 10px;">
<input name="body" type="hidden">
<div id="editor-body">{{ old('body') }}</div>
</div>
</div>
<button class="btn btn-primary" type="submit">Save Profile</button>
</form>
</div>
</div>
</div>
<script type="text/javascript">
var bodyquill = new Quill('#editor-body', {
modules: {
toolbar: [
['bold', 'italic', 'underline'],
['link', 'blockquote', 'code-block', 'image'],
[{ list: 'ordered' }, { list: 'bullet' }]
]
},
placeholder: 'Compose an epic post...',
theme: 'snow'
});
var titlequill = new Quill('#editor-title', {
modules: {
},
placeholder: 'Title Here...',
theme: 'bubble'
});
var form = document.querySelector('form');
form.onsubmit = function() {
var title = document.querySelector('input[name=title]');
title.value = JSON.stringify(titlequill.getContents());
var body = document.querySelector('input[name=body]');
body.value = JSON.stringify(bodyquill.getContents());
console.log("Submitted", $(form).serialize(), $(form).serializeArray());
// No back end to actually submit to!
alert('Open the console to see the submit data!')
return false;
};
</script>
谢谢!