I really like the extension but I'm dynamically adding text areas
through a partial, the problem I have is to render tinyMCE for the new
text areas that are added on the fly. I can call
TinymceHammer.init(); each time a new textarea is created but that
only makes a mess with the other text areas.
The Partial code is this
<div class="section">
<% new_or_existing = section.new_record? ? 'new' : 'existing' %>
<% prefix = "proposal[#{new_or_existing}_section_attributes][]" %>
<% fields_for prefix, section do |f| -%>
<div class="title">Section Title: <%= f.text_field :title %> </
div>
Description: <%= f.tinymce :description %>
<script type="text/javascript">
// new tinyMCE.init code here
TinymceHammer.init();
</script>
<%= link_to_function "remove" , "$
(this).up('.section').remove()" %>
<% end -%>
</div>
Any help resolving this issue is highly appreciated.
Cheers!
TinymceHammer.addEditor(dom_id);
Just make sure to pass a valid textarea dom attribute id to addEditor
and you should be set.
Allan
MacGregor
Tel +1 213 814 4238 Tel +1 718 865 8891 d...@allanmacgregor.com www.allanmacgregor.com Elance Profile |
_____________________________________________________
This message contains information that may be confidential and
privileged. Unless you are the addressee (or authorized to receive for
the addressee), you may not use, copy or disclose to anyone this
message or any information contained in this message. If you have
received this message in error, please advise the sender by reply
e-mail, and delete the message.
--
You received this message because you are subscribed to the Google Groups "tinymce_hammer" group.
To post to this group, send email to tinymce...@googlegroups.com.
To unsubscribe from this group, send email to tinymce_hamme...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tinymce_hammer?hl=en.
<% prefix = "proposal[#{new_or_existing}_section_attributes][]" %> the last [] is supposed to be replaced with the textarea id but because this are new objects that id doesn't exist. Do you know how could I modify that code to create custom id ? so I can pass that to the js ?? Cheers
Allan
MacGregor
Tel +1 213 814 4238 Tel +1 718 865 8891 d...@allanmacgregor.com www.allanmacgregor.com Elance Profile |
_____________________________________________________
This message contains information that may be confidential and
privileged. Unless you are the addressee (or authorized to receive for
the addressee), you may not use, copy or disclose to anyone this
message or any information contained in this message. If you have
received this message in error, please advise the sender by reply
e-mail, and delete the message.
Hi Trevor,
Yup, I think you are right I have to figure out a way to create an unique id for each of my text areas, if you check my partial code the
<% prefix = "proposal[#{new_or_existing}_section_attributes][]" %> the last [] is supposed to be replaced with the textarea id but because this are new objects that id doesn't exist. Do you know how could I modify that code to create custom id ? so I can pass that to the js ?? Cheers
<Myself.jpg>
Allan MacGregor
Tel +1 213 814 4238
Tel +1 718 865 8891
d...@allanmacgregor.com
www.allanmacgregor.com
Elance Profile
<gtalk.png> allan.ma...@gmail.com
<skype.png> macgregor_bg
<msn.png> d...@allanmacgregor.com
<aim.png> therealmacgregor
<yahoo.png> allan.m...@yahoo.com
Hi Trevor,
Yup, I think you are right I have to figure out a way to create an unique id for each of my text areas, if you check my partial code the
<% prefix = "proposal[#{new_or_existing}_section_attributes][]" %> the last [] is supposed to be replaced with the textarea id but because this are new objects that id doesn't exist. Do you know how could I modify that code to create custom id ? so I can pass that to the js ?? Cheers
<Myself.jpg>
Allan MacGregor
Tel +1 213 814 4238
Tel +1 718 865 8891
d...@allanmacgregor.com
www.allanmacgregor.com
Elance Profile
<gtalk.png> allan.ma...@gmail.com
<skype.png> macgregor_bg
<msn.png> d...@allanmacgregor.com
<aim.png> therealmacgregor
<yahoo.png> allan.m...@yahoo.com
_____________________________________________________
Allan
MacGregor
Tel +1 213 814 4238 Tel +1 718 865 8891 d...@allanmacgregor.com www.allanmacgregor.com Elance Profile |
_____________________________________________________
This message contains information that may be confidential and
privileged. Unless you are the addressee (or authorized to receive for
the addressee), you may not use, copy or disclose to anyone this
message or any information contained in this message. If you have
received this message in error, please advise the sender by reply
e-mail, and delete the message.
Hi Trevor,
Thanks for all the help so far. So I modified my code on the partial to the following
<div class="section">
<% new_or_existing = section.new_record? ? 'new' : 'existing' %>
<% prefix = "proposal[#{new_or_existing}_section_attributes][]" %>
<% fields_for prefix, section do |f| -%>
<div class="title">Section Title: <%= f.text_field :title %> </div>
Description: <%= f.tinymce :description, :id => "section_textarea" %>
<%= link_to_function "remove" , "$(this).up('.section').remove()" %>
<script type="text/javascript"> var textarea_count = 0;
function init_new_editor() {
var new_dom_id = 'text_area_' + ++text_area_count; // Create dom id and increment it by one
var textarea = document.getElementById('section_textarea'); //search for the elements with the original id
textarea.id = new_dom_id; //replace the element old id with the new unique id
TinymceHammer.addEditor(new_dom_id); //call TinymceHammer to do the replacement
} </script>
<% end -%>
</div>
Now each text area generated by the partial has the id section_textarea ... but I think my problem is on the javascript side now, two things happen one I only see the js added to the first text area created and for the new text areas no tinymce loaded or javascript after the fields. Thanks for your help in advance.
Cheers!
Allan
MacGregor
Tel +1 213 814 4238 Tel +1 718 865 8891 d...@allanmacgregor.com www.allanmacgregor.com Elance Profile |
_____________________________________________________
This message contains information that may be confidential and
privileged. Unless you are the addressee (or authorized to receive for
the addressee), you may not use, copy or disclose to anyone this
message or any information contained in this message. If you have
received this message in error, please advise the sender by reply
e-mail, and delete the message.