Need help getting Wysihat to work

Posted by slythic on Stack Overflow See other posts from Stack Overflow or by slythic
Published on 2010-05-29T21:24:19Z Indexed on 2010/05/29 21:32 UTC
Read the original article Hit count: 231

Filed under:
|
|
|
|

Hi all,

I'm using Wysihat in a rails project and am stumped by it's 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!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about forms