Question on how to load different text areas!

12 views
Skip to first unread message

Cassio Melo

unread,
Oct 23, 2009, 2:13:56 PM10/23/09
to tinymce_hammer
Hello there,

I'm still a bit confused in how to use the

I want to use a plugin for math formulas in a specific view, but not
in the others. As far as I understood, I should used the combined js
with lazyload library, so

In the header of my view:
<%= init_tinymce_hammer_if_required %>
<%= javascript_include_tag('lazyload') %>
<%= javascript_include_tag('behaviours') %>

and behaviors.js :

LazyLoad.loadOnce('/javascripts/tinymce_hammer.js', function() {
tinyMCE.init({
mode : 'exact',
elements : 'blog_post_body,blog_commentbody',
plugins :
'safari,table,paste,paste2,asciimath,asciisvg,inlinepopups',
paste_convert_headers_to_strong : true,
paste_convert_middot_lists : true,
paste_remove_spans : true,
paste_remove_styles : true,
paste_strip_class_attributes : true,
theme : 'advanced',
theme_advanced_toolbar_align : 'left',
theme_advanced_toolbar_location : 'top',
theme_advanced_buttons1 :
'undo,redo,copy,paste,pastetext,|,bold,italic,strikethrough,blockquote,charmap,bullist,numlist,removeformat,|,link,unlink,image,|,cleanup,code',
theme_advanced_buttons2 : 'asciimath,asciimathcharmap,asciisvg',
theme_advanced_buttons3 : '',
AScgiloc : 'http://www.imathas.com/editordemo/php/
svgimg.php',
ASdloc : 'http://www.imathas.com/editordemo/jscripts/tiny_mce/
plugins/asciisvg/js/d.svg'
});
});

But this is not taking effect, the editor still the same as the
default one. Can anyone help me?

Thanks in advance!
Cassio

trevorrowe

unread,
Oct 23, 2009, 2:53:34 PM10/23/09
to tinymce_hammer
It looks like you are still including the call to
"init_tinymce_hammer" in your layout head. I would guess you are also
still using one of the form helpers (like tinymce_tag, or
FormBuilder#tinymce). What is likely happening is those are
intializing tinymce.

If you want to use the lazy load method to load up the combined file,
then you shouldn't use the above helpers.

If you could paste your view code that would help.

Cassio Melo

unread,
Oct 23, 2009, 3:02:49 PM10/23/09
to tinymce_hammer
exactly ,there's just a <%= f.tinymce :statement %> in my view.. How
can I get the text box if I remove init_tinymce_hammer_if_required ?

Trevor Rowe

unread,
Oct 23, 2009, 3:13:37 PM10/23/09
to tinymce...@googlegroups.com
There are a few ways you can use tinymce_hammer. The most basic
method involves two steps,

1) call init_tinymce_hammer_if_required to you document head
2) call one of the three form helpers (like f.tinymce :statement) in
your views

This simple approach is very easy, but is not very flexible. What is
does is inserts into your page a pair of script tags. The first loads
the combined javascript file with all of tiny mce, its plugins,
language files, etc. The second script tag is a small snipit of
javascript that initializes ALL of your editors with the same set of
configuraiton options (as you define in your config/intializers/
tinymce_hammer.rb file).

If you have special needs, the above approach won't work for you.
These could include any of the follow scenarios:

1) You need multiple editors, but configured differently
2) You need delay adding an editor to the page
3) You don't want ANY javascript in your html (for the behavioral
purists).
4) ... and so on

If the basic usage works for you, stick with it. If you have one of
the special needs, you will want to remove the call to
init_tinymce_hammer_if_required and the form helper (change it from
tinymce to text_area) and then go crazy with the javascript.

In the advanced cases you will need to initialize tinymce yourself.
You can still load the combined js file, but you will need to write
your own javascript to initialize your editors.
Reply all
Reply to author
Forward
0 new messages