Khaled Karam
Khaled Karam

Reputation: 173

Epic editor can't access my textarea rails

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

Upvotes: 1

Views: 261

Answers (2)

Jignesh Gohel
Jignesh Gohel

Reputation: 6552

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.

Upvotes: 0

Legendary
Legendary

Reputation: 2242

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

Upvotes: 2

Related Questions