Amit Solanki

Avatar

A Ruby On Rails Programmer from India

Ruby Funday : A Day full of Ruby Fun

The first ruby full day event of its kind is to be held on 22nd November, 2008 at Impetus, Noida.

Here are the highlights of the day…

  • Flex on Rails
  • Internationalization Rails
  • FxRuby & ActiveRecord
  • Facebook App on Rails
  • Integrating Voice gateways in Rails
  • Soft Rock
Ruby Funday Logo

 

 

 

 

 

 

 

More details on event and venue can be found at rubyonrails.in

See you there.

How to toggle tinymce editor in rails

TinyMCE is an excellent WYSIWYG editor. The same can be used in rails with this plugin. In many cases, we need to toggle tinymce editor on/off. For this add the following lines to tiny_mce_helper.rb file of your plugin just before javascript_tag tinymce_js line in tiny_mce_init method.

tinymce_js += %Q! function toggleEditor(id) {
    if (\!tinyMCE.getInstanceById(id))
        tinyMCE.execCommand('mceAddControl', false, id);
    else
        tinyMCE.execCommand('mceRemoveControl', false, id);
    }
    !

And you can easily place a link beside your editor to toggle something similar to:

<%= link_to_function "Add/Remove Editor", "toggleEditor('name')" %>

Here name is the name of the textarea/textbox to which you are applying tinymce editor.

Recent releases of tinymce would require to use tinyMCE.get(id) instead of getInstanceById(id) in code above.

,

Before you go

Going so soon? May these links be a guide to web enlightenment.