Epic编辑器可以't访问我的文本区轨道

Epic editor can't access my textarea rails

本文关键字:访问 我的 文本区 轨道 编辑器 Epic      更新时间:2023-09-26

我正试图在rails应用程序中使用epic编辑器,但问题是它看不到我的文本区域,尽管我指定了它的id

以下是配置

<script type="text/javascript">
    var opts = { container: 'epiceditor'
        , basePath: ''
        , textarea: 'my-edit-area'
        , clientSideStorage: true
        , localStorageName: 'epiceditor'
        , useNativeFullscreen: true
        , file: { name: null
        , defaultContent: ''
          , autoSave: 100 // Set to false for no auto saving
          }
        , theme: { base: '<%= asset_path("base/epiceditor.css") %>'
          , preview: '<%= asset_path("preview/github.css") %>'
          , editor: '<%= asset_path("editor/epic-light.css") %>'
          }
        , focusOnLoad: false
        , shortcut: { modifier: 18 // alt keycode
          , fullscreen: 70 // f keycode
          , preview: 80 // p keycode
          }
        , string: { togglePreview: 'Toggle Preview Mode'
          , toggleEdit: 'Toggle Edit Mode'
          , toggleFullscreen: 'Enter Fullscreen'
          }
        , parser: typeof marked == 'function' ? marked : null
        , autogrow: false
        , button: { fullscreen: true
          , preview: true
          , bar: "auto"
          }
        }
    var editor = new EpicEditor(opts).load();
</script>

这是查看文件

<div id='epiceditor'>
    <%= text_area_tag(f['name'],f['value'], size: '20x5', class: 'form-control', id: 'my-edit-area') %>
</div>

在控制台上,它给了我这个

未捕获的类型错误:无法读取空的属性"value"

试试看(我想,你的脚本在加载html之前运行)

$( document ).ready(function() {
    // yours script here
});
<div id='epiceditor'></div>

为了从epiceditor保存数据,u必须使用js从epiceditor获取数据,并放入hidden_input

我在https://stackoverflow.com/a/35285968/936494关于如何提交输入EpicEditor的文本。请看一下,以防有帮助。