gpt4 book ai didi

javascript - Epic 编辑器无法访问我的文本区域 rails

转载 作者:行者123 更新时间:2023-11-30 16:59:29 24 4
gpt4 key购买 nike

我正在尝试在我的 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>

这是 View 文件

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

在控制台中它给了我这个

Uncaught TypeError: Cannot read property 'value' of null

最佳答案

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

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

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

为了从 epiceditor 保存数据 - 你必须使用 js 从 epiceditor 获取数据,并放入 hidden_​​input

关于javascript - Epic 编辑器无法访问我的文本区域 rails ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29142418/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com