1

I'm trying to use epic editor in my rails application, but the problem is it can't see my text area although I specified its id

Here's configuration

<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>

and here's the view file

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

In the console it gives me this

Uncaught TypeError: Cannot read property 'value' of null

Khaled Karam
  • 173
  • 1
  • 4
  • 13
  • try to add it into $(document).ready, and, also - epic reditor did not required textarea inside
    - if u have to save data from textarea - u have to use js for get it from, and put in ur hidden input (for example)
    – Legendary Mar 19 '15 at 10:48

2 Answers2

2

Try that (i think, ur script run before ur html loaded)

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

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

For save data from epiceditor - u have to use js for get data from epiceditor, and put in hidden_input

Legendary
  • 2,243
  • 16
  • 26
0

I have given a detailed answer at https://stackoverflow.com/a/35285968/936494 on how to submit the text entered into EpicEditor. Please have a look at it in case it helps.

Community
  • 1
  • 1
Jignesh Gohel
  • 6,236
  • 6
  • 53
  • 89