Button_to_remote problem on 2.3.2

Sorry about the previous aborted post… Here is the full post.

I have a link_to_remote call that works as expected (using Rails 2.3.2):

<%= link_to_remote “-”, { :url => { :action => :remove_from_cart, :id =>
cart_item.product} }, { :href => url_for(:action => :remove_from_cart,
:id => cart_item.product) } %>

It fallsback correctly when javascript is not enabled.

However, substituting with button_to_remote, does not behave correctly:

<%= button_to_remote “-”, { :url => { :action => :remove_from_cart, :id
=> cart_item.product} }, { :href => url_for(:action =>
:remove_from_cart, :id => cart_item.product) } %>

With javascript enabled it works fine. But if javascript disabled, the
fallback :href url is not followed. I.e. it does not work.

Has anybody encountered this problem. Aren’t both meant to have exactly
the same options?

Thanks for any suggestions.

On May 1, 5:17 am, Eddie R. [email protected]
wrote:

However, substituting with button_to_remote, does not behave correctly:

<%= button_to_remote “-”, { :url => { :action => :remove_from_cart, :id
=> cart_item.product} }, { :href => url_for(:action =>
:remove_from_cart, :id => cart_item.product) } %>

With javascript enabled it works fine. But if javascript disabled, the
fallback :href url is not followed. I.e. it does not work.

Have you looked at the generated html to see what might be amiss?

Fred

Definetely it won’t work, just because standalone buttons should not
do anything when javascript is disabled. That’s by design.

Dmitry

Dmitry S. wrote:

Definetely it won’t work, just because standalone buttons should not
do anything when javascript is disabled. That’s by design.

Dmitry

So it appears. button_to_remote generates the code:

which would not recognise the href. I was lulled by the description in
the API docs, believing that it says the button_to_remote behaves the
same as link_to_remote. With hindsight and closer reading, it only says
that the :url and callbacks are the same (ie silent on the Javascript
degradation).

Thanks.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs