Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Error
- undefined method `capture' for #<JqueryHelper::AccordionBuilder:0x21c170c @header="h3">
- /Users/simon/Documents/Aptana Studio/borraren/app/helpers/jquery_helper.rb:21:in `section'
- ## jquery_helper.rb
- module JqueryHelper
- def jquery_theme
- # "smoothness"
- "redmond"
- end
- def jquery_stylesheets
- css = capture { stylesheet_link_tag "ui.all.css" }
- css << capture { stylesheet_link_tag "#{jquery_theme}/jquery-ui-1.7.1.custom.css" }
- end
- class AccordionBuilder
- def initialize(header)
- @header = header
- end
- def section(name,&proc)
- throw "No block given" unless block_given?
- content = capture(&proc) <<========= jquery_helper.rb:21
- div do
- concat("<#{header}><a href='#'>#{name}</a></#{header}>",proc.binding)
- div do
- concat content,proc.binding
- end
- end
- end
- end
- def accordion(id, options = {}, &proc)
- sc = ""
- sc += "<script type='text/javascript'>"
- sc += " $(function() {"
- sc += " $('##{id}').accordion({"
- options[:header] = 'h3' if not options.include? :header
- options.each do |option,value|
- value = "'#{value}'" if option == :header
- sc += option.to_s + ":" + value.to_s + ","
- end
- sc += " });"
- sc += " });"
- sc += "</script>"
- if block_given?
- content = capture AccordionBuilder.new(options[:header]), &proc
- concat sc, proc.binding
- div :id => id do
- concat content, proc.binding <<========= This works just fine
- end
- else
- return sc
- end
- end
- end
Add Comment
Please, Sign In to add comment