If this is taking too much of your time, why don't just wrap your link in a span or div then control the class from there? Just a thought.
And I can confirm this works in 2.3.2 too, as per Nicholas post link_to "link here", new_object_path, :method => :post, :confirm => 'Press OK', :class => "css_class", :id => "css_id" Cheers! Arzumy On Jul 8, 6:21 am, Nicholas Henry <[email protected]> wrote: > OK, James, I have tested the following in Rails 2.3.2: > > link_to "link here", new_object_path, :method => :post, :confirm => > 'Press OK', :class => "css_class", :id => "css_id" > > and this does work as you would expect. > > What version are you on? > > On Tue, Jul 7, 2009 at 4:33 PM, Rob > > Biedenharn<[email protected]> wrote: > > > On Jul 7, 2009, at 3:12 PM, James Byrne wrote: > > >> I have a link-to that I wish to look somewhat like this: > > >> link_to "link here", new_object_path, > >> :method => :post, :confirm => 'Press OK', #url > >> options > >> :class => "css_class", :id => "css_id" #html > >> options > > >> In any case I can either get the url_for options to work or the html > >> options to work, but no matter how I arrange () or {} I cannot get > >> both > >> to work together. As far as I can determine, the api documents do not > >> explicitly show this case either. > > >> What I want link_to to generate is: > > >> <a href="/objects/new" > >> class="css_class" > >> id="css_id" > >> onclick="if (confirm('Press OK')) > >> { > >> var f = document.createElement('form'); > >> f.style.display = 'none'; > >> this.parentNode.appendChild(f); > >> f.method = 'POST'; > >> f.action = this.href; > >> f.submit(); > >> }; > >> return false;">link here</a> > > >> How is this done? > > > What's wrong with keeping it simple? > > > <%= link_to('link here', "/url", :method => :post, :confirm => "Press > > OK", :id => "css_id", :class => "css_class") %> > > > <a href="/url" class="css_class" id="css_id" onclick="if > > (confirm('Press OK')) { var f = document.createElement('form'); > > f.style.display = 'none'; this.parentNode.appendChild(f); f.method = > > 'POST'; f.action = this.href;var s = document.createElement('input'); > > s.setAttribute('type', 'hidden'); s.setAttribute('name', > > 'authenticity_token'); s.setAttribute('value', '1R/ > > dpXEMn3tUvmXCbVQtdHAnSw9YU36T9n2lDtZ8WlQ='); > > f.appendChild(s);f.submit(); };return false;">link here</a> > > > Surely, you can also replace "/url" with a named route as in your > > original example. Did you say what version of Rails you have? My > > example uses 2.3.2. > > > -Rob > > > Rob Biedenharn http://agileconsultingllc.com > > [email protected] --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

