Module: Apotomo::Rails::ViewHelper
- Defined in:
- lib/apotomo/rails/view_helper.rb
Overview
#url_for_event
= url_for_event(:paginate, :page => 2)
#=> http://apotomo.de/mouse/process_event_request?type=paginate&source=mouse&page=2
#widget_id
=
#=> :mouse
#children
- children.each do |kid|
= kid
Instance Method Summary collapse
-
#js_generator ⇒ Object
Returns the app JavaScript generator.
-
#multipart_form_to_event(type, options = {}, html_options = {}, &block) ⇒ Object
Creates a form that submits itself via an iFrame and executes the response in the parent window.
-
#widget_div(*args, &block) ⇒ Object
Wraps your widget content in a
div
. -
#widget_tag(tag, options = {}, &block) ⇒ Object
Wraps your widget content in a
tag
tag and sets the id.
Instance Method Details
#js_generator ⇒ Object
Returns the app JavaScript generator.
21 22 23 |
# File 'lib/apotomo/rails/view_helper.rb', line 21 def js_generator Apotomo.js_generator end |
#multipart_form_to_event(type, options = {}, html_options = {}, &block) ⇒ Object
Creates a form that submits itself via an iFrame and executes the response in the parent window. This is needed to upload files via AJAX.
Better call #form_to_event :multipart => true
and stay forward-compatible.
29 30 31 32 33 34 35 |
# File 'lib/apotomo/rails/view_helper.rb', line 29 def multipart_form_to_event(type, ={}, ={}, &block) .reverse_merge! :apotomo_iframe => true .reverse_merge! :target => :apotomo_iframe, :multipart => true # i hate rails: concat('<iframe id="apotomo_iframe" name="apotomo_iframe" style="display: none;"></iframe>'.html_safe) << form_tag(url_for_event(type, ), , &block) end |
#widget_div(*args, &block) ⇒ Object
Wraps your widget content in a div
. See #widget_tag.
38 39 40 |
# File 'lib/apotomo/rails/view_helper.rb', line 38 def (*args, &block) (:div, *args, &block) end |
#widget_tag(tag, options = {}, &block) ⇒ Object
Wraps your widget content in a tag
tag and sets the id. Feel free to pass additional html options.
- :span do
p I'm wrapped
will render
<span id="mouse">
<p>I'm wrapped</p>
</span>
Note that you can set the id
and other options manually.
- :div, id: "comments", class: "yellow"
56 57 58 59 60 |
# File 'lib/apotomo/rails/view_helper.rb', line 56 def (tag, ={}, &block) .reverse_merge!(:id => ) content_tag(tag, , &block) end |