我试图在我的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>
&#13;
这里是视图文件
<div id='epiceditor'>
<%= text_area_tag(f['name'],f['value'], size: '20x5', class: 'form-control', id: 'my-edit-area') %>
</div>
&#13;
在控制台中它给了我这个
未捕获的TypeError:无法读取属性&#39;值&#39;为null
答案 0 :(得分:2)
试试(我认为,你的脚本在加载html之前运行)
$( document ).ready(function() {
// yours script here
});
<div id='epiceditor'></div>
对于来自epiceditor的保存数据 - 你必须使用js从epiceditor获取数据,然后输入hidden_input
答案 1 :(得分:0)
我已在https://stackoverflow.com/a/35285968/936494上详细解答了如何提交输入EpicEditor的文本。如果它有帮助,请看看它。