# vim: sw=3 ts=3 ft=org

#+TITLE: Script Action Element
#+STYLE: <LINK href='../stylesheet.css' rel='stylesheet' type='text/css' />
#+AUTHOR: Rusty Klophaus (@rustyio)
#+OPTIONS:   H:2 num:1 toc:1 \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+EMAIL: 
#+TEXT: [[file:../index.org][Getting Started]] | [[file:../api.org][API]] | [[file:../elements.org][Elements]] | [[file:../actions.org][*Actions*]] | [[file:../validators.org][Validators]] | [[file:../handlers.org][Handlers]] | [[file:../config.org][Configuration Options]] | [[file:../about.org][About]]

* Script Action - #script {}

  Run some plain Javascript.

  You can access Nitrogen elements within the Javascript using the
  obj('id') function.

  For example, if you have a Nitrogen element with the id of
  'myTextBox', then "var tb = obj('myTextBox');" will make tb point to
  the myTextBox element.

  In addition, you can use obj('me') to point to the target of the
  current action, and you can use 'parent' to get the parent of an
  element, for example: "obj('me.parent.parent')".


** Usage

#+BEGIN_SRC erlang
   wf:wire(myDiv, #event { type=click, actions=#script { script="gotClick(obj('me'));" } })
#+END_SRC

** Attributes

   + script - (/string/) :: The Javascript to execute.

** See Also

   + [[./base.html][base element]]

 
