Reputation: 45
I am having styling issues with my button. Currently I have this:
<%= link_to t(:add_to_cart), '#', :onclick => "$(this).parent().submit(); return false;", :type => "button", :class => "button primary" %>
which renders this:
<a href="#" class="button" onclick="$(this).parent().submit(); return false;">Add To Cart</a>
when I change the link_to to a button_to, I've got this:
<%= button_to t(:add_to_cart), '#', :onclick => "$(this).parent().submit(); return false;", :type => "button", :class => "button primary" %>
which renders this:
<input class="button primary" onclick="$(this).parent().submit(); return false;" type="submit" value="Add To Cart">
Unfortunately, the javascript no longer works. I can see the obvious change in the markup, but why does this no longer work? I'm a designer that dabbles in Rails, so please be gentle! Seems like this could be something pretty simple. I did try :url => '#' on the button_to, which gave me other styling issues, so I reverted.
Upvotes: 0
Views: 1898
Reputation: 8442
what do you want to do with button ?
you use $(this).parent().submit(); ---> in jquery this part of code submit the form but button_to do this by default why you add it ??
then you use return false; ----> this prevent to submit form in javascript !!!
i hope i clarify something to you
Upvotes: 1