Hey all, Having trouble with this one. I''ve got Rails working great with AJAX, and I can get Prototype events to work with existing HTML, but I can''t seem to get the two to mix. When I add some new HTML to my page (i.e., :position => ''bottom''), can I use effects like "Appear" on the new content? Javascript is ignored if I send it inline as part of the Rails response, and I don''t know the DOM ID in advance, so I can''t just set it up with :complete. I''d like to be able to say something like: <%= form_remote_tag ( :update => ''mylist'', :url => { :action => :newitem }, :position => ''bottom'', :effect => ''Effect2.Appear'' ) %> Any ideas? Thanks, Jason Anderson http://www.thenewjhp.com
I solved this by telling it to Highlight the element named ''most_recent''. Then in my partial I just specify the newest row as having the id most_recent. On June 24, 2005 08:21 pm, Jason Anderson wrote:> Hey all, > > Having trouble with this one. I''ve got Rails working great with AJAX, > and I can get Prototype events to work with existing HTML, but I can''t > seem to get the two to mix. > > When I add some new HTML to my page (i.e., :position => ''bottom''), can > I use effects like "Appear" on the new content? Javascript is ignored > if I send it inline as part of the Rails response, and I don''t know > the DOM ID in advance, so I can''t just set it up with :complete. > > I''d like to be able to say something like: > > <%= form_remote_tag ( :update => ''mylist'', :url => { :action => > > :newitem }, :position => ''bottom'', :effect => ''Effect2.Appear'' ) %> > > Any ideas? > > Thanks, > > Jason Anderson > http://www.thenewjhp.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-- Scott Brooks Network Operations Manager Binary Solutions Ltd. sbrooks-7+OF9GBfT4Xe9wHmmfpqLOTW4wlIGRCZ@public.gmane.org
On 6/25/05, Jason Anderson <thenewjhp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey all, > > Having trouble with this one. I''ve got Rails working great with AJAX, > and I can get Prototype events to work with existing HTML, but I can''t > seem to get the two to mix. > > When I add some new HTML to my page (i.e., :position => ''bottom''), can > I use effects like "Appear" on the new content? Javascript is ignored > if I send it inline as part of the Rails response, and I don''t know > the DOM ID in advance, so I can''t just set it up with :complete. > > I''d like to be able to say something like: > > <%= form_remote_tag ( :update => ''mylist'', :url => { :action => > :newitem }, :position => ''bottom'', :effect => ''Effect2.Appear'' ) %>In the controller which creates the item I do this: def create_item @blah = Blah.create(@params[:blah]) flash[:new_blah] = @blah render_partial "blah", @blah end then in the partial <li id="blah-<%= blah.id %>">whatever</li> <% if blah == flash[:new_blah] %> <script>new Effect2.Appear(''blah-<%=blah.id %>'');</script> <% end %> -- Cheers Koz
> In the controller which creates the item I do this: > > def create_item > @blah = Blah.create(@params[:blah]) > flash[:new_blah] = @blah > render_partial "blah", @blah > end > > then in the partial > > <li id="blah-<%= blah.id %>">whatever</li> > > <% if blah == flash[:new_blah] %> > <script>new Effect2.Appear(''blah-<%=blah.id %>'');</script> > <% end %>I''ve tried this, and the javascript doesn''t get executed when the partial is rendered. Are you running bleeding-edge rails? I tried the prototype.js patch that supposedly enabled this behaviour, but also did not execute any javascript in a rendered partial.. Michael
I''ve seen a similar problem in IE - using the inline javascript works in FireFox. - Derek On 6/27/05, Michael Champanis <michael-MXk1+JRFB8SsTnJN9+BGXg@public.gmane.org> wrote:> > In the controller which creates the item I do this: > > > > def create_item > > @blah = Blah.create(@params[:blah]) > > flash[:new_blah] = @blah > > render_partial "blah", @blah > > end > > > > then in the partial > > > > <li id="blah-<%= blah.id %>">whatever</li> > > > > <% if blah == flash[:new_blah] %> > > <script>new Effect2.Appear(''blah-<%=blah.id %>'');</script> > > <% end %> > > I''ve tried this, and the javascript doesn''t get executed when the > partial is rendered. Are you running bleeding-edge rails? I tried the > prototype.js patch that supposedly enabled this behaviour, but also did > not execute any javascript in a rendered partial.. > > Michael > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Derek Haynes HighGroove Studios - http://www.highgroove.com Keeping it Simple. 404.593.4879