-1

quill.js を自分のサイトに統合する方法を探していますが、提供されるサポートは存在しないか、泥のように明確です。誰かが私を助けることができますか?

以下は私のコードで、現在はすべてインラインになっているため、すべてを見やすくなっています。私はクイルをページ上で実行することに成功し、それを使用してテキストを編集できますが、フォームを送信すると、エディターの値が送信されません...

エディターはその内容を非表示の入力に渡し、その内容を送信する必要がありますが、フォームを送信しているときに入力が入力されていません。

誰かが私が間違っていることを知っているなら、私はすべて耳を傾けています。誰かが問題を試みるためのより良い方法を持っているなら、私は提案を受け入れます(フォームは現在GETに設定されているので、渡されたものを簡単に調べることができます)ただし、既に作成されたコントローラーは、POST される変数を処理します。

<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>

ありがとう!

4

1 に答える 1

0

更新により、私はかなり太っていたことが判明しました。本文テキストを本文入力に挿入するために使用していた方法が、保護された単語と衝突していました。そのような衝突を省略するようにコードを作り直しました。

于 2016-10-23T19:40:42.420 に答える