Forum: Ruby on Rails rjs in multiple ajax page

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2006-04-21 22:37
(Received via mailing list)
Sorry for the long explanation but I'm having trouble integrating rjs
into my
form page. Here's my page:

<div id="posts">
<ul id="post_list"><%= render :partial => 'list_results', :collection =>
@posts %></ul>
<p><%= link_to_remote('+',
		:url => {:action => 'new'},
		:update => 'new_post',
		:loading => visual_effect(:slide_down, "new_post", :duration => 0.5))
%></p>
</div>

<div id="new_post">
</div>

This works fine and the form is rendered inside "new_post" from the
controller using render :partial => 'edit_new', :layout => false

_edit_new is as follows:

<%= form_remote_tag(:url => {:action => 'create', :id => @post}) %>
<p>subject:</p>
<p><%= text_field(:post, :subject, :width => 60) %></p>
<p>message:</p>
<p><%= text_area(:post, :content, :rows => 15, :cols => 60) %></p>
<p><%= submit_tag('add now') %></p>
<%= end_form_tag %>

Theoretically, create.rjs is used to render this, and indeed a
logger.debug
shows that to be true. Here's create.rjs:

logger.debug 'writing rjs'
page.insert_html :top, 'post_list', :partial => 'list_results', :locals
=> {
:list_results => @post }
page.visual_effect :highlight, 'post_list'

Nothing happens! Of course I know this is one of the tough parts about
rjs,
but is there anything obvious that I'm missing?

Thanks


--
View this message in context:
http://www.nabble.com/rjs-in-multiple-ajax-page-t1...
Sent from the RubyOnRails Users forum at Nabble.com.
A025f68d8100c2f0fa78c6cfcc4cbfd1?d=identicon&s=25 James McCarthy (Guest)
on 2006-04-21 22:51
Steve Ross wrote:
> Sorry for the long explanation but I'm having trouble integrating rjs
> into my
> form page. Here's my page:
>
> <div id="posts">
> <ul id="post_list"><%= render :partial => 'list_results', :collection =>
> @posts %></ul>
> <p><%= link_to_remote('+',
> 		:url => {:action => 'new'},
> 		:update => 'new_post',
> 		:loading => visual_effect(:slide_down, "new_post", :duration => 0.5))

Sent from the RubyOnRails Users forum at Nabble.com.


You have to take the :update out of the link_to_remote.

It will work when that it gone.
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2006-04-21 23:14
(Received via mailing list)
It wasn't the link_to_remote that was a problem. That's straightforward
AJAX.
It's the second one. However, I took your suggestion and changed the
link_to_remote and created a new.rjs. It doesn't work either. I've
reduced
this to a trivial case and that works; however, inside my real page it
fails. Is there something that can disrupt rjs responses?

How would one know?

Thanks
--
View this message in context:
http://www.nabble.com/rjs-in-multiple-ajax-page-t1...
Sent from the RubyOnRails Users forum at Nabble.com.
59ea1b450935b9d70abfec4186b7a4d5?d=identicon&s=25 Jeff Coleman (progressions)
on 2006-04-22 07:02
Steve Ross wrote:
> It wasn't the link_to_remote that was a problem. That's straightforward
> AJAX.
> It's the second one. However, I took your suggestion and changed the
> link_to_remote and created a new.rjs. It doesn't work either. I've
> reduced
> this to a trivial case and that works; however, inside my real page it
> fails. Is there something that can disrupt rjs responses?
>
> How would one know?
>
> Thanks
> --
> View this message in context:
> http://www.nabble.com/rjs-in-multiple-ajax-page-t1...
> Sent from the RubyOnRails Users forum at Nabble.com.

I have tried using the :locals parameter with a :partial call in RJS but
I couldn't get it to work.

You might try a test without the :locals call, see how that goes.

Jeff Coleman
This topic is locked and can not be replied to.