Skip to content
gdotdesign edited this page Nov 3, 2014 · 4 revisions

The events behavior gives you the ability to map DOM \ Events to instance methods with the on DSL:

class MyComponent < Fron::Component
  component :text, :span

  # Add events directly
  on :click, :method
  # Delegate events
  on :click, 'span', :method

  def method
  end
end

Syntax

on( "event", "selector" (optional), "method" )

  • The first argument is always the event type.
  • The last argument is always the method to call.
  • The middle argument is the selector to match, if given it will delegate the events.
  • If the method does not exists on the component an error will be raised.
Clone this wiki locally