Forum: Ruby on Rails Problem with tiny_mce

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2009-01-16 18:08
(Received via mailing list)
I have a problem with the tiny_mce, i have this javascript in my view
(that javacript works fine because when i didn't had tiny_mce it
worked fine):

   . <script>
   .   function change(value)
   .   {
   .
   .     <% for layout in @layouts %>
   .
   .       if (value == "<%= layout.temp_id %>")
   .       {
   .         document.getElementById
("text_area_html_content").innerHTML = '<%= layout.body %>';
  .       }
  .
  .     <% end %>
  .
  .   }
  . </script>

And also I have this in the HTML

  . <%= collection_select(:temp,:temp, @templates, :id, :name ,
{:class => 'selecttag'}, :onchange => "change(value);") %>
  .
  . <%= f.text_area :body, {:id => "text_area_html_content",:class =>
'mceEditor'} %>


So...

The 'onchange' event of the select tag changes the innerHTML of the
textarea using the javascript above. When I had the text without the
tiny_mce it worked fine, but now with the tiny_mce the innerHTML it
doesn't works.

Can anyone help me, any ideas?

Thanks,
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2009-01-16 21:13
(Received via mailing list)
I solved the issue:

This was the the old script:

  tinyMCE.get('editor1').setContent('<h1>This is Ronen Site 1</h1>');

   . <script>
   .   function change(value)
   .   {
   .
   .     <% for layout in @layouts %>
   .
   .       if (value == "<%= layout.temp_id %>")
   .       {
   .         document.getElementById
("text_area_html_content").innerHTML = '<%= layout.body %>';
  .       }
  .
  .     <% end %>
  .
  .   }
  . </script>

I changed it to:

   . <script>
   .   function change(value)
   .   {
   .
   .     <% for layout in @layouts %>
   .
   .       if (value == "<%= layout.temp_id %>")
   .       {
 tinyMCE.get('text_area_html_content').setContent('<%= layout.body
%>');
  .       }
  .
  .     <% end %>
  .
  .   }
  . </script>

Hope it helps someone in the future,

Elioncho
This topic is locked and can not be replied to.