Module: RightRails::Helpers::Basic
- Defined in:
- lib/right_rails/helpers/basic.rb
Overview
Basic RightRails feature helpers container
Instance Method Summary collapse
-
#rightjs_require_module(*list) ⇒ Object
Requires the RightJS modules.
-
#rightjs_scripts(*modules) ⇒ Object
Automatically generates the javascript include tags.
-
#rjs {|generator| ... } ⇒ Object
The javascript generator access from the templates.
-
#rjs_tag(&block) ⇒ Object
Same as the rjs method, but will wrap the generatated code in a <script></script> tag.
-
#update_page(&block) ⇒ Object
Replacing the prototype’s javascript generator with our own javascript generator so that the #link_to_function method was working properly.
Instance Method Details
#rightjs_require_module(*list) ⇒ Object
Requires the RightJS modules
66 67 68 |
# File 'lib/right_rails/helpers/basic.rb', line 66 def rightjs_require_module(*list) RightRails::Helpers.require_js_module self, *list end |
#rightjs_scripts(*modules) ⇒ Object
Automatically generates the javascript include tags
USAGE:
<%= rightjs_scripts %>
you can also predefine the list of modules to load
<%= rightjs_scripts 'lightbox', 'calendar' %>
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/right_rails/helpers/basic.rb', line 16 def rightjs_scripts(*modules) = modules.last.is_a?(Hash) ? modules.pop : nil rightjs_require_module *modules scripts = RightRails::Helpers.required_js_files(self) scripts << unless .nil? javascript_include_tag *scripts end |
#rjs {|generator| ... } ⇒ Object
The javascript generator access from the templates
USAGE:
Might be used both directly or with a block
<%= link_to 'Delete', '#', :onclick => rjs[@record].hide('fade') %>
<%= link_to 'Delete', '#', :onclick => rjs{|page| page[@record].hide('fade') }
36 37 38 39 40 |
# File 'lib/right_rails/helpers/basic.rb', line 36 def rjs(&block) generator = RightRails::JavaScriptGenerator.new(self) yield(generator) if block_given? generator end |
#rjs_tag(&block) ⇒ Object
Same as the rjs method, but will wrap the generatated code in a <script></script> tag
EXAMPLE:
<%= rjs_tag do |page|
page.alert 'boo'
end %>
51 52 53 |
# File 'lib/right_rails/helpers/basic.rb', line 51 def rjs_tag(&block) javascript_tag rjs(&block).to_s end |
#update_page(&block) ⇒ Object
Replacing the prototype’s javascript generator with our own javascript generator so that the #link_to_function method was working properly
59 60 61 |
# File 'lib/right_rails/helpers/basic.rb', line 59 def update_page(&block) rjs(&block).to_s end |