Hello - I''m trying to use a form_remote_tag to make a submit button to
fire off an Ajax call. When I add this form_remote_tag code I don''t
see a submit button where there should be one.
I''m following the example given in the Agile Web Development book
starting on page 122.
The code I''m using as follows
<% form_remote_tag :url => { :action => :add_to_cart, :id => product
}
do %>
<%= submit_tag "Add to Cart" %>
<% end %>
I also have enabled the javascript_include_tag :defaults like this
<%= javascript_include_tag :defaults %>
Any ideas why the button wouldn''t show up?
Thanks,
Clem
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Clem Rock wrote:> Hello - I''m trying to use a form_remote_tag to make a submit button to > fire off an Ajax call. When I add this form_remote_tag code I don''t > see a submit button where there should be one. > > I''m following the example given in the Agile Web Development book > starting on page 122. > > The code I''m using as follows > > > <% form_remote_tag :url => { :action => :add_to_cart, :id => product } > do %> > <%= submit_tag "Add to Cart" %> > <% end %>form_remote_tag => http://caboo.se/doc/classes/ActionView/Helpers/PrototypeHelper.html#M005162 This tag also has a non-block form. Does that work ? Alan -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Clem,
Your code needs to look like this:
<%= form_remote_tag :url => { :action => :add_to_cart, :id =>
product }
do %>
<%= submit_tag "Add to Cart" %>
<%= end_form_tag %>
The <% ... %> tags will evaluate the code between them without
outputting the result into the HTML. The <%= ... %> tags, on the other
hand, will output the result.
Hope that helps,
Matt Buck
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Matt Buck wrote:> Clem, > > Your code needs to look like this: > > <%= form_remote_tag :url => { :action => :add_to_cart, :id => product } > do %> > <%= submit_tag "Add to Cart" %> > <%= end_form_tag %> > > The <% ... %> tags will evaluate the code between them without > outputting the result into the HTML. The <%= ... %> tags, on the other > hand, will output the result. > > Hope that helps, > Matt BuckNot exactly true... On 1.2 RC1 or edge, the proper syntax for forms is: <% form_tag :action => ''foo'' do %> <%= submit_tag ''Foo!'' %> <% end %> If you combine this block form with the <%= %> and it bombs because it does not return a valid ruby statement, causing a syntax error. If you are not on edge rails, or RC1, then use the non block form_tag: <%= form_tag :action => ''foo'' %> <%= submit_tag ''Foo!'' %> <%= end_form_tag %> I suspect you are using the block form with a version of rails that does not support it. This makes whatever is inside your form tag simply disappear. So either use the non-block form_tag, or switch to RC1 or edge rails. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ok - it must be just the version of rails I was running:
this the the version that worked for me:
<%= form_remote_tag :url => { :action => :add_to_cart, :id =>
product }
%>
<%= submit_tag "Add to Cart" %>
<%= end_form_tag %>
Thanks so much for your help!
>> Clem,
>>
>> Your code needs to look like this:
>>
>> <%= form_remote_tag :url => { :action => :add_to_cart, :id
=> product }
>> do %>
>> <%= submit_tag "Add to Cart" %>
>> <%= end_form_tag %>
>>
>> The <% ... %> tags will evaluate the code between them without
>> outputting the result into the HTML. The <%= ... %> tags, on the
other
>> hand, will output the result.
>>
>> Hope that helps,
>> Matt Buck
>
> Not exactly true...
>
> On 1.2 RC1 or edge, the proper syntax for forms is:
>
> <% form_tag :action => ''foo'' do %>
> <%= submit_tag ''Foo!'' %>
> <% end %>
>
> If you combine this block form with the <%= %> and it bombs because
it
> does not return a valid ruby statement, causing a syntax error.
>
> If you are not on edge rails, or RC1, then use the non block form_tag:
>
> <%= form_tag :action => ''foo'' %>
> <%= submit_tag ''Foo!'' %>
> <%= end_form_tag %>
>
> I suspect you are using the block form with a version of rails that does
> not support it. This makes whatever is inside your form tag simply
> disappear. So either use the non-block form_tag, or switch to RC1 or
> edge rails.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---