【问题标题】:Epic editor can't access my textarea railsEpic 编辑器无法访问我的 textarea rails
【发布时间】:2016-02-09 15:14:57
【问题描述】:

我正在尝试在我的 rails 应用程序中使用史诗编辑器,但问题是虽然我指定了它的 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>

在控制台中它给了我这个

未捕获的类型错误:无法读取 null 的属性“值”

【问题讨论】:

  • 尝试将其添加到 $(document).ready 中,并且,epic reditor 不需要
    内的 textarea - 如果您必须保存数据从 textarea - 你必须使用 js 来获取它,并放入你的隐藏输入(例如)

标签: javascript jquery ruby-on-rails epiceditor


【解决方案1】:

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

$( document ).ready(function() {
    // yours script here
});

<div id='epiceditor'></div>

从史诗编辑器保存数据 - 你必须使用 js 从史诗编辑器获取数据,并放入 hidden_​​input

【讨论】:

    【解决方案2】:

    我已经在https://stackoverflow.com/a/35285968/936494给出了关于如何提交输入EpicEditor的文本的详细解答。如果有帮助,请查看它。

    【讨论】:

      猜你喜欢
      • 2012-10-14
      • 2018-08-24
      • 1970-01-01
      • 1970-01-01
      • 2019-12-25
      • 2022-08-20
      • 1970-01-01
      • 1970-01-01
      • 2019-07-29
      相关资源
      最近更新 更多