Hey- I''m using ROR 1.0 and script.aculo.us 1.5.1. I''ve been trying unsuccessfully to render a partial in a DIV, but can''t seem to get the right combination of stuff to make it work. There seems to be a few different ways of going about it. Right now I can render a partial. What do I need to to render the partial in a div? Here is what it looks like so far: # index.rhtml <%= start_form_tag :action => ''search'' %> Enter Student Name: <%= text_field_with_auto_complete :student, :full_name %> <%= submit_tag "Get Student Records" %> <%= end_form_tag %> # CONTROLLER def search # Get all the PLogs associated with user_id, student_id studentid = params[:student] fullname = studentid[:full_name] name = Student.find_by_full_name(fullname) @archives = PhoneLog.find(:all, :conditions => ["user_id = ? AND student_id = ?", @session[''user''].id, name.id]) # Render the tabs render :partial => ''tabs'' end # _tabs.rhtml <div id="tabs"> <ul> <li><a href="#" onclick="Effect.Appear(''new_plog''); Effect.SwitchOff(''contentcenter''); return false;"><span>New Plog</span></a></li> <% for archive in @archives %> <li><a href="#" title= <%= archive.id %> ><span> <%archive.call_end %> </span></a></li> <% end %> <li><a href="#" title="contacts"><span>Contacts</span></a></li> <li><a href="#" title="archive"><span>Archive</span></a></li> </ul> </div>
Keith, under "/app/views/layout/" you put a [controllername].rhtml with a bunch of html headers and what not (yes or no generated with some more ruby code), and the magical tag: <html> <head></head> <body> ... lot of stuff ... <div id="whateveryoulike"> <%= @content_for_layout %> </div> </body> Rails will use this and replace the <%= @content_for_layout %> tag with all the generated output from your partial. Is that what you were looking for? Regards, Gerard. On Wednesday 04 January 2006 15:13, Keith Donaldson tried to type something like:> Hey- > > I''m using ROR 1.0 and script.aculo.us 1.5.1. I''ve been trying > unsuccessfully to render a partial in a DIV, but can''t seem to get the > right combination of stuff to make it work. There seems to be a few > different ways of going about it. Right now I can render a partial. > What do I need to to render the partial in a div? Here is what it > looks like so far: > > # index.rhtml > <%= start_form_tag :action => ''search'' %> > Enter Student Name: <%= text_field_with_auto_complete :student, :full_name > %> <%= submit_tag "Get Student Records" %> > <%= end_form_tag %> > > # CONTROLLER > def search > # Get all the PLogs associated with user_id, student_id > studentid = params[:student] > fullname = studentid[:full_name] > name = Student.find_by_full_name(fullname) > @archives = PhoneLog.find(:all, > > :conditions => ["user_id = ? AND student_id = ?", > > @session[''user''].id, name.id]) > > # Render the tabs > render :partial => ''tabs'' > end > > > # _tabs.rhtml > <div id="tabs"> > <ul> > <li><a href="#" onclick="Effect.Appear(''new_plog''); > Effect.SwitchOff(''contentcenter''); return false;"><span>New > Plog</span></a></li> > <% for archive in @archives %> > <li><a href="#" title= <%= archive.id %> ><span> <%> archive.call_end %> </span></a></li> > <% end %> > <li><a href="#" title="contacts"><span>Contacts</span></a></li> > <li><a href="#" title="archive"><span>Archive</span></a></li> > </ul> > </div> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-- "Who cares if it doesn''t do anything? It was made with our new Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..." My $Grtz =~ Gerard; ~ :wq!
Thanks Gerard: I guess I left out part of the story. I''m looking for AJAX-type solution that will update a DIV after the user has submitted a form. Thanks for your help. On 1/4/06, Gerard <mailing@gp-net.nl> wrote:> Keith, > > under "/app/views/layout/" you put a [controllername].rhtml with a bunch of > html headers and what not (yes or no generated with some more ruby code), and > the magical tag: > <html> > <head></head> > <body> > > ... lot of stuff ... > > <div id="whateveryoulike"> > <%= @content_for_layout %> > </div> > > </body> > > Rails will use this and replace the <%= @content_for_layout %> tag with all > the generated output from your partial. > > Is that what you were looking for? > > Regards, > > Gerard. > > > > On Wednesday 04 January 2006 15:13, Keith Donaldson tried to type something > like: > > Hey- > > > > I''m using ROR 1.0 and script.aculo.us 1.5.1. I''ve been trying > > unsuccessfully to render a partial in a DIV, but can''t seem to get the > > right combination of stuff to make it work. There seems to be a few > > different ways of going about it. Right now I can render a partial. > > What do I need to to render the partial in a div? Here is what it > > looks like so far: > > > > # index.rhtml > > <%= start_form_tag :action => ''search'' %> > > Enter Student Name: <%= text_field_with_auto_complete :student, :full_name > > %> <%= submit_tag "Get Student Records" %> > > <%= end_form_tag %> > > > > # CONTROLLER > > def search > > # Get all the PLogs associated with user_id, student_id > > studentid = params[:student] > > fullname = studentid[:full_name] > > name = Student.find_by_full_name(fullname) > > @archives = PhoneLog.find(:all, > > > > :conditions => ["user_id = ? AND student_id = ?", > > > > @session[''user''].id, name.id]) > > > > # Render the tabs > > render :partial => ''tabs'' > > end > > > > > > # _tabs.rhtml > > <div id="tabs"> > > <ul> > > <li><a href="#" onclick="Effect.Appear(''new_plog''); > > Effect.SwitchOff(''contentcenter''); return false;"><span>New > > Plog</span></a></li> > > <% for archive in @archives %> > > <li><a href="#" title= <%= archive.id %> ><span> <%> > archive.call_end %> </span></a></li> > > <% end %> > > <li><a href="#" title="contacts"><span>Contacts</span></a></li> > > <li><a href="#" title="archive"><span>Archive</span></a></li> > > </ul> > > </div> > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > -- > "Who cares if it doesn''t do anything? It was made with our new > Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..." > > My $Grtz =~ Gerard; > ~ > :wq! > > > >
On 4.1.2006, at 18.47, Keith Donaldson wrote:> Thanks Gerard: > > I guess I left out part of the story. I''m looking for AJAX-type > solution that will update a DIV after the user has submitted a form.You need to use form_remote_tag instead of normal form_tag to make it ajax-y. <%= form_remote_tag(:url => { :controller => "trainingparts", :action => "add_part_with_ajax", :id => @training }, :update => ''details'', :loading => "$(''new-part-desc'').innerHTML = ''Saving...''", :complete => "$(''new-part-desc'').innerHTML = ''Add a part to training''; Field.clear (''trainingpart_hrs'',''trainingpart_mins'', ''trainingpart_secs'', ''trainingpart_length'')") %> The :update parameter is where you need to put the id of the div you want updated. See the complete api [1] for more details. The Rails AJAX video [2] is also worth watching. //jarkko [1] http://api.rubyonrails.com/classes/ActionView/Helpers/ JavaScriptHelper.html#M000435 [2] http://www.rubyonrails.com/media/video/rails-ajax.mov> > Thanks for your help. > > On 1/4/06, Gerard <mailing@gp-net.nl> wrote: >> Keith, >> >> under "/app/views/layout/" you put a [controllername].rhtml with a >> bunch of >> html headers and what not (yes or no generated with some more ruby >> code), and >> the magical tag: >> <html> >> <head></head> >> <body> >> >> ... lot of stuff ... >> >> <div id="whateveryoulike"> >> <%= @content_for_layout %> >> </div> >> >> </body> >> >> Rails will use this and replace the <%= @content_for_layout %> tag >> with all >> the generated output from your partial. >> >> Is that what you were looking for? >> >> Regards, >> >> Gerard. >> >> >> >> On Wednesday 04 January 2006 15:13, Keith Donaldson tried to type >> something >> like: >>> Hey- >>> >>> I''m using ROR 1.0 and script.aculo.us 1.5.1. I''ve been trying >>> unsuccessfully to render a partial in a DIV, but can''t seem to >>> get the >>> right combination of stuff to make it work. There seems to be a few >>> different ways of going about it. Right now I can render a partial. >>> What do I need to to render the partial in a div? Here is what it >>> looks like so far: >>> >>> # index.rhtml >>> <%= start_form_tag :action => ''search'' %> >>> Enter Student Name: <%= >>> text_field_with_auto_complete :student, :full_name >>> %> <%= submit_tag "Get Student Records" %> >>> <%= end_form_tag %> >>> >>> # CONTROLLER >>> def search >>> # Get all the PLogs associated with user_id, student_id >>> studentid = params[:student] >>> fullname = studentid[:full_name] >>> name = Student.find_by_full_name(fullname) >>> @archives = PhoneLog.find(:all, >>> >>> :conditions => ["user_id = ? AND student_id = ?", >>> >>> @session[''user''].id, name.id]) >>> >>> # Render the tabs >>> render :partial => ''tabs'' >>> end >>> >>> >>> # _tabs.rhtml >>> <div id="tabs"> >>> <ul> >>> <li><a href="#" onclick="Effect.Appear(''new_plog''); >>> Effect.SwitchOff(''contentcenter''); return false;"><span>New >>> Plog</span></a></li> >>> <% for archive in @archives %> >>> <li><a href="#" title= <%= archive.id %> >>> ><span> <%>>> archive.call_end %> </span></a></li> >>> <% end %> >>> <li><a href="#" title="contacts"><span>Contacts</span></a></ >>> li> >>> <li><a href="#" title="archive"><span>Archive</span></a></li> >>> </ul> >>> </div> >>> _______________________________________________ >>> Rails mailing list >>> Rails@lists.rubyonrails.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> -- >> "Who cares if it doesn''t do anything? It was made with our new >> Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..." >> >> My $Grtz =~ Gerard; >> ~ >> :wq! >> >> >> >> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2363 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060104/11320f44/smime.bin
Success! I had to change the form tag in the view: <%= form_remote_tag(:url => { :controller => "plog", :action => "search", :id => @archives }, :update => ''tabs'') %> Enter Student Name: <%= text_field_with_auto_complete :student, :full_name%> <%= submit_tag "Get Student Records" %> <%= end_form_tag %> .... I tried using the form_remote_tag before but had not used :id. My guess this makes it work. Where can you find documentation that explains what CALLBACKS and AJAX_OPTIONS? I also removed the div tags from my partial. Thanks for the help. kd On 1/4/06, Jarkko Laine <jarkko@jlaine.net> wrote:> On 4.1.2006, at 18.47, Keith Donaldson wrote: > > > Thanks Gerard: > > > > I guess I left out part of the story. I''m looking for AJAX-type > > solution that will update a DIV after the user has submitted a form. > > You need to use form_remote_tag instead of normal form_tag to make it > ajax-y. > > <%= form_remote_tag(:url => { :controller => "trainingparts", > :action => "add_part_with_ajax", > :id => @training }, > :update => ''details'', > :loading => "$(''new-part-desc'').innerHTML > ''Saving...''", > :complete => "$(''new-part-desc'').innerHTML > ''Add a part to training''; Field.clear > (''trainingpart_hrs'',''trainingpart_mins'', ''trainingpart_secs'', > ''trainingpart_length'')") %> > > The :update parameter is where you need to put the id of the div you > want updated. See the complete api [1] for more details. The Rails > AJAX video [2] is also worth watching. > > //jarkko > > [1] http://api.rubyonrails.com/classes/ActionView/Helpers/ > JavaScriptHelper.html#M000435 > [2] http://www.rubyonrails.com/media/video/rails-ajax.mov > > > > > Thanks for your help. > > > > On 1/4/06, Gerard <mailing@gp-net.nl> wrote: > >> Keith, > >> > >> under "/app/views/layout/" you put a [controllername].rhtml with a > >> bunch of > >> html headers and what not (yes or no generated with some more ruby > >> code), and > >> the magical tag: > >> <html> > >> <head></head> > >> <body> > >> > >> ... lot of stuff ... > >> > >> <div id="whateveryoulike"> > >> <%= @content_for_layout %> > >> </div> > >> > >> </body> > >> > >> Rails will use this and replace the <%= @content_for_layout %> tag > >> with all > >> the generated output from your partial. > >> > >> Is that what you were looking for? > >> > >> Regards, > >> > >> Gerard. > >> > >> > >> > >> On Wednesday 04 January 2006 15:13, Keith Donaldson tried to type > >> something > >> like: > >>> Hey- > >>> > >>> I''m using ROR 1.0 and script.aculo.us 1.5.1. I''ve been trying > >>> unsuccessfully to render a partial in a DIV, but can''t seem to > >>> get the > >>> right combination of stuff to make it work. There seems to be a few > >>> different ways of going about it. Right now I can render a partial. > >>> What do I need to to render the partial in a div? Here is what it > >>> looks like so far: > >>> > >>> # index.rhtml > >>> <%= start_form_tag :action => ''search'' %> > >>> Enter Student Name: <%> >>> text_field_with_auto_complete :student, :full_name > >>> %> <%= submit_tag "Get Student Records" %> > >>> <%= end_form_tag %> > >>> > >>> # CONTROLLER > >>> def search > >>> # Get all the PLogs associated with user_id, student_id > >>> studentid = params[:student] > >>> fullname = studentid[:full_name] > >>> name = Student.find_by_full_name(fullname) > >>> @archives = PhoneLog.find(:all, > >>> > >>> :conditions => ["user_id = ? AND student_id = ?", > >>> > >>> @session[''user''].id, name.id]) > >>> > >>> # Render the tabs > >>> render :partial => ''tabs'' > >>> end > >>> > >>> > >>> # _tabs.rhtml > >>> <div id="tabs"> > >>> <ul> > >>> <li><a href="#" onclick="Effect.Appear(''new_plog''); > >>> Effect.SwitchOff(''contentcenter''); return false;"><span>New > >>> Plog</span></a></li> > >>> <% for archive in @archives %> > >>> <li><a href="#" title= <%= archive.id %> > >>> ><span> <%> >>> archive.call_end %> </span></a></li> > >>> <% end %> > >>> <li><a href="#" title="contacts"><span>Contacts</span></a></ > >>> li> > >>> <li><a href="#" title="archive"><span>Archive</span></a></li> > >>> </ul> > >>> </div> > >>> _______________________________________________ > >>> Rails mailing list > >>> Rails@lists.rubyonrails.org > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> -- > >> "Who cares if it doesn''t do anything? It was made with our new > >> Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..." > >> > >> My $Grtz =~ Gerard; > >> ~ > >> :wq! > >> > >> > >> > >> > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > -- > Jarkko Laine > http://jlaine.net > http://odesign.fi > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >