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. -- Posted via http://www.ruby-forum.com/.
On May 1, 5:17 am, Eddie Ridwan <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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. >Have you looked at the generated html to see what might be amiss? Fred> Has anybody encountered this problem. Aren''t both meant to have exactly > the same options? > > Thanks for any suggestions. > -- > Posted viahttp://www.ruby-forum.com/.
Definetely it won''t work, just because standalone buttons should not do anything when javascript is disabled. That''s by design. Dmitry
Dmitry Sokurenko wrote:> Definetely it won''t work, just because standalone buttons should not > do anything when javascript is disabled. That''s by design. > > DmitrySo it appears. button_to_remote generates the code: <input href="/store/remove_from_cart/1" onclick="new Ajax.Request(''/store/remove_from_cart/1'', {asynchronous:true, evalScripts:true, parameters:''authenticity_token='' + encodeURIComponent(''xzGTsqm4ySuhtDKGQq4SIwVn7oIipLPmBq21CUOoQvY='')});" type="button" value="-" /> </td> 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. -- Posted via http://www.ruby-forum.com/.