Textile editor helper help!

phew, riddle me this.

i can render the tool bar from a regular action, but if I render the
‘edit’ form via either rjs or _partial, the toolbar does not render?

for rjs i tried doing a replace_html and insert, but the toolbar does
not render. only when i call from a regular action. what noobish mistake
am i making?

when the toolbar does not render, i see no errors in my log, however, i
do see the javascript in firebug.

mixplate wrote:

phew, riddle me this.

i can render the tool bar from a regular action, but if I render the
‘edit’ form via either rjs or _partial, the toolbar does not render?

for rjs i tried doing a replace_html and insert, but the toolbar does
not render. only when i call from a regular action. what noobish mistake
am i making?

when the toolbar does not render, i see no errors in my log, however, i
do see the javascript in firebug.

If you are rendering from AJAX, this most likely won’t work because the
initialization is handled (essentially) by window.onload()

mixplate wrote:

phew, riddle me this.

i can render the tool bar from a regular action, but if I render the
‘edit’ form via either rjs or _partial, the toolbar does not render?

for rjs i tried doing a replace_html and insert, but the toolbar does
not render. only when i call from a regular action. what noobish mistake
am i making?

when the toolbar does not render, i see no errors in my log, however, i
do see the javascript in firebug.

Update: I’ve updated the textile_editor_initialize() helper to support
initializing editors via AJAX. Update your local copy and check the
lib/textile_editor_helper.rb file for more information :slight_smile:

hi, is it v0.2. that has the update?

hmmm,

i have a div id ‘edit_form’ where i use rjs to insert the partial that
holds the edit_form. how would i call tthe

<%= textile_editor_initialize ‘edit_form’-%> ?

mixplate wrote:

hi, is it v0.2. that has the update?

hmmm,

i have a div id ‘edit_form’ where i use rjs to insert the partial that
holds the edit_form. how would i call tthe

<%= textile_editor_initialize ‘edit_form’-%> ?

In the template that contains that div you’ll need to have

<%= textile_editor_initialize %>

Then, in the partial, add

<%= textile_editor_initialize %>

again - the helper nows uses request.xhr? to determine how to initialize
the editor.

hi thanks, i will look into it for its very imperative for my
application !

also, any idea for this?

when the button is pressed, they expand.

thanks for the help and awesome plugin!

Chris S. wrote:

mixplate wrote:

phew, riddle me this.

i can render the tool bar from a regular action, but if I render the
‘edit’ form via either rjs or _partial, the toolbar does not render?

for rjs i tried doing a replace_html and insert, but the toolbar does
not render. only when i call from a regular action. what noobish mistake
am i making?

when the toolbar does not render, i see no errors in my log, however, i
do see the javascript in firebug.

Update: I’ve updated the textile_editor_initialize() helper to support
initializing editors via AJAX. Update your local copy and check the
lib/textile_editor_helper.rb file for more information :slight_smile:

thanks for your reply, ive tried however, just cant seem to get it to
render.

###################
#index.rhtml

<div id = 'edit_form_div' <div id = 'note' # here is where i render notes </div

###################
#_edit_form
<% form_tag :action => ‘update’, :id => @note do%>
<%= textile_editor ‘note’, ‘note_a’ -%><
<%= textile_editor_initialize -%>
<% end %>

##########
rjs when edit button in note div is pressedi

page.hide ‘note’
page.insert_html :bottom, ‘edit_form_div’, :partial => 'edit_form

#########

now your post says tto do something like?
#index

#partial
<% form_tag :action => ‘update’, :id => @note do%>
<%= textile_editor ‘note’, ‘note_a’ -%><
<%= textile_editor_initialize -%>
<% end %>

from reading the directions, aint it only one time to use <%=
textile_editor_initialize %>? the current svn has the latest src
correct?\

thanks for any help

mixplate wrote:

thanks for your reply, ive tried however, just cant seem to get it to
render.

###################
#index.rhtml

<div id = 'edit_form_div' <div id = 'note' # here is where i render notes </div

###################
#_edit_form
<% form_tag :action => ‘update’, :id => @note do%>
<%= textile_editor ‘note’, ‘note_a’ -%><
<%= textile_editor_initialize -%>
<% end %>

##########
rjs when edit button in note div is pressedi

page.hide ‘note’
page.insert_html :bottom, ‘edit_form_div’, :partial => 'edit_form

#########

now your post says tto do something like?
#index

#partial
<% form_tag :action => ‘update’, :id => @note do%>
<%= textile_editor ‘note’, ‘note_a’ -%><
<%= textile_editor_initialize -%>
<% end %>

from reading the directions, aint it only one time to use <%=
textile_editor_initialize %>? the current svn has the latest src
correct?\

thanks for any help

I will need to update the directions to be more specific - you should
only call the initialize once in a regular render. The latest update
allows you to call initialize again when dealing with AJAX. Calling
initialize from your edit.rhtml will load in the proper support files
(JS and CSS). Then, in the partial, initialize works slightly
differently since it’s a AJAX request - it simply drops in a script tag
to enable any instance of TEH that are in the partial.

Can you post the response from the AJAX request (using Firebug)?

Also, just to be sure, run “rake textile_editor_helper:install” again
and restart mongrel/webrick.

in my index

<%= textile_editor_initialize -%>

rjs

page.insert_html :bottom, :eform, :partial => ‘note_edit_form’


edit form

<% form_tag :action => ‘update’, :id => @note do%>

Title
<%= text_field 'note', 'title' %>

Note
<%= textile_editor 'note', 'note' -%>

<%= textile_editor_initialize -%>

<%= submit_tag ‘Save’ %> — <%= link_to ‘Cancel?’, { :action => ‘index’
}, :method => “post” %>

<% end %>

###############

try {

new Insertion.Bottom(“eform”, “\n\n\n\n\n\n\t\n\t\n\t\n\t\n \n\n <form
action=”/account/update/17-test-title

" method=“post”>\n\n\t

<label
for=“howto_title”>Title
\n\t<input id=“note_title”

name=“note[title]” size=“30” type=“text” value=“test title”
/>

\n\n\n\n\n\t

<label for

=“howto_howto”>Note
\n\n\t<textarea cols=“40”
id=“note_note” name=“note[note]” rows

=“20”>test note

\n\t<link
href="/stylesheets/textile-editor.css?1181957714" media=

“screen” rel=“Stylesheet” type=“text/css” />\n<script
src="/javascripts/textile-editor.js?1181957714

" type=“text/javascript”>\n<script
type=“text/javascript”>\nEvent.observe(window, ‘load’

, function() {\nTextileEditor.initialize(‘note_note’,
‘extended’);\n});\n\t\n\t\t\n\n\t<input

name=“commit” type=“submit” value=“Save” /> — <a
href="/account" onclick="var f = document

.createElement(‘form’); f.style.display = ‘none’;
this.parentNode.appendChild(f); f.method = ‘POST’;

f.action = this.href;var m = document.createElement(‘input’);
m.setAttribute(‘type’, ‘hidden’); m.setAttribute

(‘name’, ‘_method’); m.setAttribute(‘value’, ‘post’);
f.appendChild(m);f.submit();return false;">Cancel

?\n\n\t\n\n");

new Effect.Highlight(“note”,{duration:0.5});

new Effect.Appear(“note”,{duration:0.5});

} catch (e) { alert(‘RJS error:\n\n’ + e.toString()); alert('new
Insertion.Bottom(“eform”, "\n\n

\n\n\n\n\t\n\t\n\t\n\t\n \n\n <form
action=\"/account/update/17-test-title\" method

=\“post\”>\n\n\t

<label
for=\“howto_title\”>Title
\n\t<input id=\"note_title

\" name=\“note[title]\” size=\“30\” type=\“text\”
value=\“test title\” />

\n\n

\n\n\n\t

<label
for=\“howto_howto\”>Note
\n\n\t<textarea
cols=\“40\” id

=\“note_note\” name=\“note[note]\” rows=\“20\”>test
note

\n\t<link href=

\"/stylesheets/textile-editor.css?1181957714\" media=\“screen\”
rel=\“Stylesheet\” type=

\“text/css\” />\n<script
src=\"/javascripts/textile-editor.js?1181957714\"
type=\"text/javascript

\">\n<script
type=\“text/javascript\”>\nEvent.observe(window, ‘load’,
function()

{\nTextileEditor.initialize(‘note_note’,
‘extended’);\n});\n\t\n\t\t\n\n\t<input

name=\“commit\” type=\“submit\” value=\“Save\” /> — <a
href=\"/account\" onclick=

\"var f = document.createElement(‘form’); f.style.display =
‘none’; this.parentNode.appendChild

(f); f.method = ‘POST’; f.action = this.href;var m =
document.createElement(‘input’); m.setAttribute

(‘type’, ‘hidden’); m.setAttribute(‘name’, ‘_method’);
m.setAttribute(‘value’, ‘post’); f

.appendChild(m);f.submit();return
false;\">Cancel?\n\n\t\n\n");\nnew Effect.Highlight

(“note”,{duration:0.5});\nnew
Effect.Appear(“note”,{duration:0.5});’); throw e }

It seems like your copy of TEH is not the latest - run “svn info” and
see if you have at least revision 126. Looking at your output, I see an
Event.observe() call, as well as the inclusion of TEH’s support files -
these shouldn’t be included when the request is an AJAX call.

Hi Chris, thank you so much for your help. i was able to get the
updates installed correctly and my app is working fine. thanks again!

Chris S. wrote:

It seems like your copy of TEH is not the latest - run “svn info” and
see if you have at least revision 126. Looking at your output, I see an
Event.observe() call, as well as the inclusion of TEH’s support files -
these shouldn’t be included when the request is an AJAX call.