Class: Lapillus::OnClick
- Defined in:
- lib/lapillus/behaviours.rb
Overview
duplication between OnClick and AjaxLink todo: add test
Instance Attribute Summary
Attributes inherited from Component
#behaviours, #identifier, #model, #property, #visible
Instance Method Summary collapse
-
#initialize(component_to_refresh = nil) ⇒ OnClick
constructor
A new instance of OnClick.
- #render_to_element(element) ⇒ Object
Methods inherited from Component
#add_behaviour, #behaviour, #has_behaviour?, #has_model?, #has_parent?, #parent, #path, #response_page=, #session, #value, #webpage
Methods inherited from RenderableComponent
#on_render, #render_behaviours, #render_children, #render_component, #render_container, #visible?
Constructor Details
#initialize(component_to_refresh = nil) ⇒ OnClick
Returns a new instance of OnClick.
134 135 136 137 |
# File 'lib/lapillus/behaviours.rb', line 134 def initialize(component_to_refresh=nil) super("", :model => component_to_refresh) component_to_refresh.add_behaviour(UniqueIdentifier.new) if has_model? end |
Instance Method Details
#render_to_element(element) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/lapillus/behaviours.rb', line 139 def render_to_element(element) if has_model? javascript = "new Ajax.Updater('#{value.path}', '', { evalScripts: true, method:'get', parameters: { listener:'#{parent.path}' }}); return false;" else javascript = "new Ajax.Request('', { method: 'get', parameters: { listener:'#{parent.path}' }}); return false;" end attribute = REXML::Attribute.new("onclick", javascript) # # TODO: this should be the default for attributes in # # Lapillus somewhere! # def attribute.to_string # return "#@expanded_name=\"#@value\"" # end element.add_attribute(attribute) end |