Guest User

Untitled

a guest
Jun 13th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. ## Error
  2. undefined method `capture' for #<JqueryHelper::AccordionBuilder:0x21c170c @header="h3">
  3.  
  4. /Users/simon/Documents/Aptana Studio/borraren/app/helpers/jquery_helper.rb:21:in `section'
  5.  
  6.  
  7. ## jquery_helper.rb
  8.  
  9. module JqueryHelper
  10.  
  11. def jquery_theme
  12. # "smoothness"
  13. "redmond"
  14. end
  15.  
  16. def jquery_stylesheets
  17. css = capture { stylesheet_link_tag "ui.all.css" }
  18. css << capture { stylesheet_link_tag "#{jquery_theme}/jquery-ui-1.7.1.custom.css" }
  19. end
  20.  
  21. class AccordionBuilder
  22.  
  23. def initialize(header)
  24. @header = header
  25. end
  26.  
  27. def section(name,&proc)
  28. throw "No block given" unless block_given?
  29. content = capture(&proc) <<========= jquery_helper.rb:21
  30. div do
  31. concat("<#{header}><a href='#'>#{name}</a></#{header}>",proc.binding)
  32. div do
  33. concat content,proc.binding
  34. end
  35. end
  36. end
  37. end
  38.  
  39. def accordion(id, options = {}, &proc)
  40. sc = ""
  41. sc += "<script type='text/javascript'>"
  42. sc += " $(function() {"
  43. sc += " $('##{id}').accordion({"
  44.  
  45. options[:header] = 'h3' if not options.include? :header
  46.  
  47. options.each do |option,value|
  48. value = "'#{value}'" if option == :header
  49. sc += option.to_s + ":" + value.to_s + ","
  50. end
  51.  
  52. sc += " });"
  53. sc += " });"
  54. sc += "</script>"
  55.  
  56. if block_given?
  57. content = capture AccordionBuilder.new(options[:header]), &proc
  58. concat sc, proc.binding
  59. div :id => id do
  60. concat content, proc.binding <<========= This works just fine
  61. end
  62. else
  63. return sc
  64. end
  65. end
  66.  
  67. end
Add Comment
Please, Sign In to add comment