scarfacedeb / rails_admin_globalize_field

Tabbed interface and custom field type for globalize translations for Rails_admin
MIT License
50 stars 60 forks source link

Ckeditor Integration #11

Closed jaemo closed 9 years ago

jaemo commented 9 years ago

Hi! Great engine to start with. I've run into a bit of an issue wherein I need to be able to make textareas that contain translated content behave as ckeditor.

I have CK working fine with other fields that do not require translation. I'm not sure how to go about doing this though.

Really what I need is something like this:

rails_admin do
    configure :translations, :globalize_tabs
    navigation_label "Content"
    field :translations do
      field :content, :ck_editor
      ....
    end
    field :source
  end

But that doesn't work. At present, is there any way of getting this engine to render a textarea as a CK_editor? I'm pretty sure it's as simple as adding a classname to the textarea, I'm not sure if this would lie under this engine's ability or if it's something that needs to be altered on Rails Admin itself.

Thoughts?

jaemo commented 9 years ago

Anyone else wanting to accomplish this: Save the gem's version of rails_admin/ui.js file into /app/assets/javascripts/rails_admin/ui.js

Then add the following lines:

$(window).load(function(){ console.log( $("textarea") ) $("textarea").each(function(index, element){ $(this).addClass("ckeditor") }); })

NB: this will make EVERY textarea turn into a ckeditor instance. It's what I wanted for the current project I am working on but you may decide to be more specific when targeting your textareas.