stiweb2003
stiweb2003

Reputation: 73

Activeadmin with Tinymce CDN

I'm fairly new to rails. I have a Rails 3.2.13 app running ActiveAdmin. I'm trying to integrate tinyMCE as my editor for the text areas. I want to use the quick install CDN hosted by Cachefly.

I'm able to add the reference to the minified tinymce javascript on the cdn by adding

config.register_javascript 'http://tinymce.cachefly.net/4.0/tinymce.min.js'

that renders the script tag below in my header.

<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>

How can I add the initializer script below to my head in activeadmin on all the pages?

<script>
    tinymce.init({selector:'textarea'});
</script>

I'm a Rails noob. It's probably something simple, but I searched everywhere and I can't seem to figure it out.

Any help would be greatly appreciated.

Upvotes: 1

Views: 969

Answers (1)

JCalculator
JCalculator

Reputation: 11

You can simply add a javascript file as well after you add tinymce to the config. So it would look like:

config.register_javascript 'http://tinymce.cachefly.net/4.0/tinymce.min.js'
config.register_javascript 'admin/custom.js'

Where custom.js would be located in:

app/assets/javascripts/admin/custom.js

And the contents would be your desired js code that will execute on all pages:

(function() {
    tinymce.init({selector:'textarea'});
})();

Upvotes: 1

Related Questions