# Button\_to\_remote problem on 2.3.2

**URL:** <https://www.ruby-forum.com/t/button-to-remote-problem-on-2-3-2/166936>\
**Category:** Rails\
**Created:** [May 1, 2009, 6:17am UTC](https://www.ruby-forum.com/t/button-to-remote-problem-on-2-3-2/166936 "2009-05-01T06:17:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/dfb087/32.png) [@eddier](https://www.ruby-forum.com/u/eddier)\
**Post date:** [May 1, 2009, 6:17am UTC](https://www.ruby-forum.com/t/button-to-remote-problem-on-2-3-2/166936/1 "2009-05-01T06:17:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eddier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/dfb087/32.png) [@eddier](https://www.ruby-forum.com/u/eddier)\
**Post date:** [May 1, 2009, 9:51am UTC](https://www.ruby-forum.com/t/button-to-remote-problem-on-2-3-2/166936/2 "2009-05-01T09:51:28Z")

</div>

On May 1, 5:17 am, Eddie R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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

---

<div class="post-metadata">

**Author:** ![eddier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/dfb087/32.png) [@eddier](https://www.ruby-forum.com/u/eddier)\
**Post date:** [May 1, 2009, 11:42am UTC](https://www.ruby-forum.com/t/button-to-remote-problem-on-2-3-2/166936/3 "2009-05-01T11:42:08Z")

</div>

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

Dmitry

---

<div class="post-metadata">

**Author:** ![eddier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/dfb087/32.png) [@eddier](https://www.ruby-forum.com/u/eddier)\
**Post date:** [May 1, 2009, 12:12pm UTC](https://www.ruby-forum.com/t/button-to-remote-problem-on-2-3-2/166936/4 "2009-05-01T12:12:24Z")

</div>

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.
