Peter Fitzgibbons
2006-Feb-02 20:33 UTC
[Rails] What''s the javascript to submit an AJAX Form?
HI Everyone, How do I form the href on an anchor so I can create a link-style submit for an ajax form? In this snippet, the INPUT generated by #submit_tag works OK, but the anchor results in the AJAX replacing the whole page? Can I make the anchor/href submit the AJAX form as well? Thank you! I have this (list.rhtml): <%= form_remote_tag :url => {:action=>:ajax_list_option_table}, :html => {:name=>''option_list_form''}, :update => ''option_table'', :complete => "Toggle.display(''auto_link_link'')"; %> <h1>Options</h1> <p></p> <table border="0"> <tr> <td/> <td align="right" cols="2"> <%= submit_tag "GO" %> <a class="button" href="javascript:document.option_list_form.submit();" name="go" >GO</a> </td> </tr> </table> <%= end_form_tag -%> <table> <tbody id="option_list_table"> </tbody> </table> -- ------------------------------ Forget the icing. Bake the Cake! - the epi-centered developer ------------------------------ Peter Fitzgibbons -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060202/85d14431/attachment.html
You are supposed to be able to add a :submit option, which will get the value of One (and only one as far as I know... I just asked about that myself) element (by id) in the form. Is there any other way? - Matt On 2/2/06, Peter Fitzgibbons <peter.fitzgibbons@gmail.com> wrote:> > HI Everyone, > > How do I form the href on an anchor so I can create a link-style submitfor an ajax form? > > In this snippet, the INPUT generated by #submit_tag works OK, but the > anchor results in the AJAX replacing the whole page? > > Can I make the anchor/href submit the AJAX form as well? > > Thank you! > > > I have this (list.rhtml): > > <%= form_remote_tag :url => {:action=>:ajax_list_option_table}, > :html => {:name=>''option_list_form''}, > :update => ''option_table'', > :complete => " Toggle.display(''auto_link_link'')"; > %> > > <h1>Options</h1> > <p></p> > <table border="0"> > <tr> > <td/> > <td align="right" cols="2"> > <%= submit_tag "GO" %> > <a class="button" href="javascript: document.option_list_form.submit();" > name="go" >GO</a> > </td> > </tr> > </table> > > <%= end_form_tag -%> > > <table> > <tbody id="option_list_table"> > </tbody> > </table> > > -- > ------------------------------ > Forget the icing. Bake the Cake! > - the epi-centered developer > ------------------------------ > Peter Fitzgibbons > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Matt Secoske http://www.secosoft.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060202/bd87caa4/attachment.html