Topic: Form_remote_tag not displaying button

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
Edit/Delete Message

Re: Form_remote_tag not displaying button

Is any of the form showing up? Check the HTML output. I think "form_remote_tag" is a standard output tag, not like "form_for" (although I do believe there is "form_remote_for")

try

<%= form_remote_tag :url => { :action => :add_to_cart, :id => product } %>
<%= submit_tag "Add to Cart" %>
<%= end_form_tag %>

notice how everything is in output blocks, not evaluation blocks

Re: Form_remote_tag not displaying button

well - it now it shows the button but the button doesn't respond.   

it seems to need the do block but then it cancels out the action.


Weird!

Thanks for your help!

Re: Form_remote_tag not displaying button

Ok Problem solved - 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 %>