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?, #on_render, #parent, #path, #render_component, #response_page=, #session, #value, #visible?, #webpage
Constructor Details
#initialize(component_to_refresh = nil) ⇒ OnClick
Returns a new instance of OnClick.
126 127 128 129 |
# File 'lib/lapillus/behaviours.rb', line 126 def initialize(component_to_refresh=nil) super(nil, component_to_refresh) component_to_refresh.add_behaviour(UniqueIdentifier.new) if has_model? end |
Instance Method Details
#render_to_element(element) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/lapillus/behaviours.rb', line 131 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 |