Macrow / rails_kindeditor

Kindeditor for Ruby on Rails
260 stars 108 forks source link

必须要刷新才能出现富文本编辑器。 #92

Closed hofffmancx closed 7 years ago

hofffmancx commented 7 years ago

每次新建文章时,必须要刷新一下,才能出现富文本编辑器kindeditor。这样是正常的吗?

我的代码: https://github.com/hofffmancx/rails_kindeditor_example

谢谢。

Macrow commented 7 years ago

请仔细阅读使用说明啊

Work with Turbolinks5

Create a file app/assets/javascripts/load_kindeditor.coffee

  # coffeescript code
  $(document).on 'turbolinks:before-cache', ->
    KindEditor.remove('.rails_kindeditor')

  $(document).on 'turbolinks:load', ->
    $('.rails_kindeditor').each ->
      KindEditor.create "##{$(this).attr('id')}", "allowFileManager": true, "uploadJson": $(this).data('upload'), "fileManagerJson": $(this).data('filemanager'), "width": '100%', "height": '300'

Make sure the file is loaded from your app/assets/javascripts/application.js

hofffmancx commented 7 years ago

非常感谢大神