Class Apotomo::Widget
In: lib/apotomo/widget.rb
Parent: Cell::Rails

Accessing Parameters

Apotomo tries to prevent you from having to access the global params hash. We have the following concepts to retrieve input data.

  1. Configuration values are available both in render and triggered states. Pass those in widget

when creating the widget tree. Use options for reading.

  has_widgets do |root|
    root << widget(:mouse_widget, 'mum', :favorites => ["Gouda", "Chedar"])

and read in your widget state

  def display
    @cheese = options[:favorites].first
  1. Request data from forms etc. is available through event.data in the triggered states.

Use the #[] shortcut to access values directly.

  def update(evt)
    @cheese = Cheese.find evt[:cheese_id]

Methods

Included Modules

Hooks TreeNode Onfire EventMethods WidgetShortcuts JavascriptMethods

External Aliases

name -> widget_id

Attributes

name  [R] 
options  [R] 
visible  [W] 

Public Class methods

Public Instance methods

Returns the widget named widget_id if it‘s a descendent or self.

Invokes state and hopefully returns the rendered content.

Renders and returns a view for the current state. That‘s why it is usually called at the end of a state method.

Options

Example:

 class MouseWidget < Apotomo::Widget
   def eat
     render
   end

render the view eat.haml.

 render :text => "alert('SQUEAK!');"

issues a squeaking alert dialog on the page.

Renders the widget (instance or id).

[Validate]