Class: Lapillus::PostWithAjax

Inherits:
AttributeModifier show all
Defined in:
lib/lapillus/behaviours.rb

Instance Attribute Summary collapse

Attributes inherited from Component

#behaviours, #identifier, #model, #property, #visible

Instance Method Summary collapse

Methods inherited from AttributeModifier

#render_to_element

Methods inherited from Component

#add_behaviour, #behaviour, #has_behaviour?, #has_model?, #has_parent?, #parent, #path, #response_page=, #session, #webpage

Methods inherited from RenderableComponent

#on_render, #render_behaviours, #render_children, #render_component, #render_container, #render_to_element, #visible?

Constructor Details

#initialize(component_to_refresh = nil) ⇒ PostWithAjax

Returns a new instance of PostWithAjax.



157
158
159
160
161
# File 'lib/lapillus/behaviours.rb', line 157

def initialize(component_to_refresh=nil)
  super(:onsubmit)
  @component_to_refresh = component_to_refresh
  component_to_refresh.add_behaviour(UniqueIdentifier.new) if !component_to_refresh.nil?
end

Instance Attribute Details

#component_to_refreshObject

Returns the value of attribute component_to_refresh.



156
157
158
# File 'lib/lapillus/behaviours.rb', line 156

def component_to_refresh
  @component_to_refresh
end

Instance Method Details

#valueObject



163
164
165
166
# File 'lib/lapillus/behaviours.rb', line 163

def value
  updateScript = "new Ajax.Updater('#{component_to_refresh.path}', '', { evalScripts: true, method: 'post', parameters:Form.serialize(this)}); return false;"
  return updateScript
end