ruby-on-railsjquery-uijquery-ui-css-framework

Modifying Rails helpers to add HTML classes


I'm starting to use the jQuery UI CSS Framework for an app, which means I have to start adding classes to everything. So, for example, I want to make all buttons jQuery-themed, which means adding a class to all buttons.

I imagine there's some way in Rails to modify the helpers so I don't have to manually add a :class => 'blah' to every button, but I can't work it out. Is this possible, or does anybody have any better ideas?


Solution

  • You just need override the helper method with this class add. In your application_helper.rb

      def button_to(name, options = {}, html_options = {})
        super(name, options, html_options.merge(:class => 'blah'))
      end