Topic: Tiny MCE and Text Area weirdness

I've got a simple remote_form_tag with a text area that's smoothed with TinyMCE.  When I submit the form, the contents of the form don't get posted:


Parameters: {"commit"=>"Add Comment", "action"=>"create", "controller"=>"comments", "story"=>"9", "comment"=>{"comment_body"=>""}}

Note the comment_body is blank.  If I remove TinyMCE then it works just fine..  The truly weird part is that if I try to submit the comment a second time, the text from the first try goes through.

e.g.

1. I type 'hello' and submit.
2. Comment gets posted but is blank
3. I add a new comment that says 'wow, that was weird'
4. Comment gets posted but says 'hello'

Anyone have any ideas for me? (besides not using TinyMCE?)

Re: Tiny MCE and Text Area weirdness

Ok, solved my own problem.. here's the solution for those who run into it.  In your form_remote_tag, add this code:

:before => "tinyMCE.triggerSave(true,true)"

That should do it.  Thanks to this great post from Dave Astels:
http://daveastels.com/2006/10/29/using- … ails-ajax/

Re: Tiny MCE and Text Area weirdness

viniosity wrote:

I've got a simple remote_form_tag with a text area that's smoothed with TinyMCE.  When I submit the form, the contents of the form don't get posted:


Parameters: {"commit"=>"Add Comment", "action"=>"create", "controller"=>"comments", "story"=>"9", "comment"=>{"comment_body"=>""}}

Note the comment_body is blank.  If I remove TinyMCE then it works just fine..  The truly weird part is that if I try to submit the comment a second time, the text from the first try goes through.

e.g.

1. I type 'hello' and submit.
2. Comment gets posted but is blank
3. I add a new comment that says 'wow, that was weird'
4. Comment gets posted but says 'hello'

Anyone have any ideas for me? (besides not using TinyMCE?)

Could you tell me how you implemented tinyMCE? I can't get it to work, I followed the article on the rails wiki. What does your rhtml look like for it?

paul

Re: Tiny MCE and Text Area weirdness

<%= javascript_include_tag "tiny_mce/tiny_mce.js" %>
<script language="javascript" type="text/javascript">
tinyMCE.init({
    mode : "textareas",
    width : "530",
    height: "200",
    theme : "advanced",
    theme_advanced_buttons1 : "bold, italic, underline, strikethrough, jusifyleft,justifyright,justifycenter,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_disable : "charmap, hr, sub, sup, media, image, anchor, link, unlink, help, html, styleselect, formatselect, code, removeformat, cleanup, visualaid",
    theme_advanced_toolbar_location : "top"
    });
</script>

You'll also need prototype and defaults as usual..

Re: Tiny MCE and Text Area weirdness

viniosity wrote:

<%= javascript_include_tag "tiny_mce/tiny_mce.js" %>
<script language="javascript" type="text/javascript">
tinyMCE.init({
    mode : "textareas",
    width : "530",
    height: "200",
    theme : "advanced",
    theme_advanced_buttons1 : "bold, italic, underline, strikethrough, jusifyleft,justifyright,justifycenter,justifyfull,bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_disable : "charmap, hr, sub, sup, media, image, anchor, link, unlink, help, html, styleselect, formatselect, code, removeformat, cleanup, visualaid",
    theme_advanced_toolbar_location : "top"
    });
</script>

You'll also need prototype and defaults as usual..

Thanks for the reply. Strange, I can't get it to render at all. I have the include in my layout, uses tiny_mce in my controller and I used your code as a copy in my view. For some reason I get nothing.

Re: Tiny MCE and Text Area weirdness

PaulS wrote:

Thanks for the reply. Strange, I can't get it to render at all. I have the include in my layout, uses tiny_mce in my controller and I used your code as a copy in my view. For some reason I get nothing.

What folder are your tiny_mce files in?

Re: Tiny MCE and Text Area weirdness

viniosity wrote:
PaulS wrote:

Thanks for the reply. Strange, I can't get it to render at all. I have the include in my layout, uses tiny_mce in my controller and I used your code as a copy in my view. For some reason I get nothing.

What folder are your tiny_mce files in?

vendor/plugins

Last edited by PaulS (2007-09-10 13:53:43)

Re: Tiny MCE and Text Area weirdness

PaulS wrote:

vendor/plugins

Hmm.. why did you put them there?  They should be in public/javascripts

Line 1 of my code

<%= javascript_include_tag "tiny_mce/tiny_mce.js" %>

expects to find the tiny mce folder in public/javascripts/ with the files themselves in public/javascripts/tiny_mce

Re: Tiny MCE and Text Area weirdness

viniosity wrote:
PaulS wrote:

vendor/plugins

Hmm.. why did you put them there?  They should be in public/javascripts

Line 1 of my code

<%= javascript_include_tag "tiny_mce/tiny_mce.js" %>

expects to find the tiny mce folder in public/javascripts/ with the files themselves in public/javascripts/tiny_mce

My bad, I do have them in public/javascripts
In my layout I did:
<% # Include TinyMCE before other JS to avoid problems -%>
<%= javascript_include_tiny_mce_if_used %>
<%= tiny_mce if using_tiny_mce? %>
in the <head> before the other statements

then in my controller:
uses tiny_mce

then in my view I tried your code, plus various variations of my own.

Re: Tiny MCE and Text Area weirdness

The code I gave you was taken from my layout file.. in my view I don't have anything special.. just the text area call:

<%= text_area :foo, :bar %>

Perhaps you should start simple by replacing your layout code with mine and add complexity to see where it breaks..

Re: Tiny MCE and Text Area weirdness

Got it working, thanks for the help. The issue was due to my own mistake. Thanks again.

paul