I have the following view template: <%= form_remote_tag :update => "new_item", :url => {:action => ''create''}, :before => %(Element.show(''spinner'')), :success => %(Element.hide(''spinner'')) %> <div id="new_item"> </div> =====================================================================Here is the controller: def create @category = Category.new(@params[:category]) if @category.save @new_item = Category.find_by_sql("select max(category) as last_category, id from categories") render_text "<tr><td>" + @new_item[:id] + "</td><td>" + @new_item[:category] + "</td></tr>" else render_action ''new'' end end I''m a complete newbie, any help would be appreciated. Thanks, Bill -- Posted via http://www.ruby-forum.com/.
Bill wrote:> I have the following view template: > > <%= form_remote_tag :update => "new_item", > :url => {:action => ''create''}, > :before => %(Element.show(''spinner'')), > :success => %(Element.hide(''spinner'')) %> > > <div id="new_item"> > > </div> > > =====================================================================> Here is the controller: > > def create > @category = Category.new(@params[:category]) > if @category.save > @new_item = Category.find_by_sql("select max(category) as > last_category, id from categories") > render_text "<tr><td>" + @new_item[:id] + "</td><td>" + > @new_item[:category] + "</td></tr>" > else > render_action ''new'' > end > end > > I''m a complete newbie, any help would be appreciated. > > Thanks, > BillI forgot to mention, my view controller also has the following input field: <%= text_field "category", "category", "size"=>20, "maxlength"=>20 %> -- Posted via http://www.ruby-forum.com/.
Ben Reubenstein
2006-Mar-26 21:31 UTC
[Rails] Re: Updating query results in real time with AJAX
Hi Bill ~ What seems to be the issue? Just posting source makes it tough for us to offer advice. ~ Thx, Ben On 3/26/06, Bill <bduenskie@gmail.com> wrote:> Bill wrote: > > I have the following view template: > > > > <%= form_remote_tag :update => "new_item", > > :url => {:action => ''create''}, > > :before => %(Element.show(''spinner'')), > > :success => %(Element.hide(''spinner'')) %> > > > > <div id="new_item"> > > > > </div> > > > > =====================================================================> > Here is the controller: > > > > def create > > @category = Category.new(@params[:category]) > > if @category.save > > @new_item = Category.find_by_sql("select max(category) as > > last_category, id from categories") > > render_text "<tr><td>" + @new_item[:id] + "</td><td>" + > > @new_item[:category] + "</td></tr>" > > else > > render_action ''new'' > > end > > end > > > > I''m a complete newbie, any help would be appreciated. > > > > Thanks, > > Bill > > > I forgot to mention, my view controller also has the following input > field: > <%= text_field "category", "category", "size"=>20, "maxlength"=>20 %> > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Reubenstein http://www.benr75.com
Ben Reubenstein wrote:> Hi Bill ~ > > What seems to be the issue? Just posting source makes it tough for us > to offer advice. > > ~ Thx, > > Ben > > On 3/26/06, Bill <bduenskie@gmail.com> wrote: >> > </div> >> > @new_item[:category] + "</td></tr>" >> >> > -- > Ben Reubenstein > http://www.benr75.comWhen you submit the form to enter the new category i''d like to display the new category without refreshing the page, ala AJAX. -- Posted via http://www.ruby-forum.com/.
Ted Korolchuk
2006-Mar-27 05:05 UTC
[Rails] Re: Re: Updating query results in real time with AJAX
Have you tried doing this? Is there some reason you can''t get it to work? Not to be rude, but I think you should try to do this yourself first, and if you have trouble with it, then report it to the list. If you can''t figure out where to start, read. On 3/26/06, Bill <bduenskie@gmail.com> wrote:> > When you submit the form to enter the new category i''d like to display > the new category without refreshing the page, ala AJAX. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > 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/20060327/a9a5e183/attachment.html