How do you prevent a newline after a button_to. I thought <%= button_to blabla -%> was meant to do it, but it didn''t I think I got it generated <div> tags around the button code. How do you do it? thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
andrew.ohnstad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Jan-29 14:16 UTC
Re: how to prevent a newline after a button_to
On Jan 29, 4:27 am, bingo bob <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> How do you prevent a newline after a button_to. > > I thought <%= button_to blabla -%> was meant to do it, but it didn''t I > think I got it generated <div> tags around the button code. > > How do you do it? >This is something that gets tossed around from time to time. The official (barely) agreed upon stance is: "The div is for HTML4.01/XHTML1.0 strict compliance. An input can only be contained by one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins" or "del". " [ http://dev.rubyonrails.org/ticket/10422 ] But this annoys me too. There are a few ways of handling this. button_to creates a form tag with a class of "button_to". So in your stylesheet, you should be able to do something with .button_to .form .div and remove the spacing. (I haven''t tried this myself yet, and I''m not a css whiz, so YMMV). If you care less about strict compliance, and want to get rid of the div tags totally, then the following in you application.rb will work: module Helpers module UrlHelper def button_to(name, options = {}, html_options = nil) html_options = (html_options || {}).stringify_keys convert_boolean_attributes!(html_options, %w( disabled )) if confirm = html_options.delete("confirm") html_options["onclick"] = "return # {confirm_javascript_function(confirm)};" end options = {:only_path=>false}.update(options) url = options.is_a?(String) ? options : url_for(options) name ||= url html_options.symbolize_keys! tag(:input, html_options.merge({ :type => "button", :value => name, :onclick => (html_options[:onclick] ? "#{html_options [:onclick]}; " : "") + "window.location.href=''#{url_for(options)}'';" })) end end end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---