Permalink
Browse files

added header_html option for accordion, added ui options support for …

…accordion
  • Loading branch information...
1 parent 04f7fda commit ff2734d3e0bb37304e02673b0e9974d474c3dd2a @michaek michaek committed Mar 24, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/jquery_ui_rails_helpers/accordion_helper.rb
View
7 lib/jquery_ui_rails_helpers/accordion_helper.rb
@@ -12,16 +12,17 @@ class JqueryUiAccordion < JqueryUiRailsHelpers::JqueryUiBase
def initialize(opts={}, controller, &block)
@panels = []
@controller = controller
+ @ui_options = {}.merge( opts[:ui] )
@html_options = { :id => :accordion }.merge( opts[:html] )
yield self if block_given?
end
def panel(panel_id, panel_title, opts={}, &block)
content = @controller.capture(&block)
- opts = { :html => {} }.merge(opts)
+ opts = { :html => {}, :header_html => {} }.merge(opts)
- header = content_tag( :h3, link_to( content_tag( :span, panel_title ), "#%s" % panel_id ) )
+ header = content_tag( :h3, link_to( content_tag( :span, panel_title ), "#%s" % panel_id ), opts[:header_html] )
panel = content_tag( :div, content, opts[:html].merge( :id => panel_id ) )
@panels << (header + panel)
@@ -32,7 +33,7 @@ def render
@html = content_tag( :div, @panels.join('').html_safe, @html_options)
# generate the javascript for jquery ui
- @javascript = javascript_tag "$(function(){ $('#%s').accordion(); });" % @html_options[:id]
+ @javascript = javascript_tag "$(function(){ $('#%s').accordion(%s); });" % [@html_options[:id], @ui_options.to_json]
# return self, for chaining
self

0 comments on commit ff2734d

Please sign in to comment.