Jeff,
You can only render once per action. Since you are explicitly rendering
text from your myrandom action, the rjs template is never looked at.
Anytime you put an explicit render call in your action, you short-circuit it
from looking at templates. If there aren''t any render calls in your
action,
upon exiting your action method ActionController will first look for a
myrandom.rhtml file to render. If that file exists, it will render that
template and send the response. If it doesn''t exist, it will look for
a
myrandom.rjs template, render it, and send a response. (Failing all of
that, you''ll get a template does not exist error.)
In your example, assuming you do not have a myrandom.rhtml file in the views
folder, it will render the rjs template if you simply remove the call to
render_text (and leave the action empty).
To have the text inserted into the DOM in the <div id="myrandom"
/> you''ll
have to change the myrandom.rjs template to:
page.replace_html ''myrandom'', ''here is some
text''
page.visual_effect :highlight, ''myrandom'', :duration => 3
Hope that helps.
On 7/6/06, Jeff <ijk@speakeasy.net> wrote:>
> I have the following:
>
> layout:
>
> <%= javascript_include_tag :defaults %>
> [...]
> <div id="menu">
> <div id="myrandom"></div>
> <%= render :partial => ''menu'' %>
> </div>
>
>
> menu partial:
>
> <%= link_to_remote "Generate Text",
> :update => ''myrandom'',
> :url => { :action => ''myrandom'' } %>
>
>
> myrandom :
>
> def myrandom
> render_text "here is some text"
> end
>
>
> myrandom.rjs
>
> page.visual_effect :highlight, ''myrandom'', :duration
=> 3
>
>
>
> When I click action, the text is rendered, however the rjs does not
> seem to take effect, I was trying to get rjs working in a more
> complicated scenario, but hopefully if I can understand why it is not
> working here I can apply it to my other scenario.
>
> Any pointers appreciated.
>
> Thanks,
>
> Jeff
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060706/9e30fe04/attachment.html