Search code examples
javascriptruby-on-railsformswysiwygwysihat

Need help getting Wysihat to work


I'm using Wysihat in a rails project and am stumped by its inability to bind to my textarea named post_description (model name Post field name description).

I have the following in my head tag:

    <%= javascript_include_tag 'prototype_1.7'%>
    <%= javascript_include_tag 'wysihat' %>

    <script type="text/javascript" charset="utf-8">
    document.on("dom:loaded", function() {
      var editor = WysiHat.Editor.attach('post_description');
      var toolbar = new WysiHat.Toolbar(editor);
      toolbar.addButtonSet(WysiHat.Toolbar.ButtonSets.Basic);

      // Hide our error message if the editor loads fine
      $('error').hide();
    });
  </script>

I'm able to see Wysihat works (the bold, italic, and underline tools are shown and when click works as intended). The following in the source of the posts/new HTML:

<div id="post_description_editor" class="editor" contenteditable="true"></div>
<textarea cols="40" id="post_description" name="post[description]" rows="20" style="display: none; "></textarea>

However, when I type something in the description field and click submit the post validation fails saying the description field is empty. Anyone have any clue on how I can get this to work?

Thanks in advance!


Solution

  • This will definitely help you:

    http://github.com/80beans/wysihat-engine