Alien-GvaScript

 view release on metacpan or  search on metacpan

doc/html/Form.html  view on Meta::CPAN


    </div>
  </div>

    </div>
  </div>
  <div class="TN_node" id="METHODS">
    <h2 class="TN_label">METHODS</h2>
    <div class="TN_content">
        <div class="TN_node" id="destroy">
    <h3 class="TN_label">destroy</h3>
    <div class="TN_content">
      <pre>  gvascript_form.destroy()</pre>

<p>instance destructor -  will unregister the GvaScript.Form instance from the GvaScript.Forms namespace and will remove all of its observers.</p>

    </div>
  </div>
  <div class="TN_node" id="getId">
    <h3 class="TN_label">getId</h3>
    <div class="TN_content">
      <pre>  gvascript_form.getId()</pre>

<p>returns the id of the form element that the gvascript_form instance is wrapped around.</p>

    </div>
  </div>
  <div class="TN_node" id="fire">
    <h3 class="TN_label">fire</h3>
    <div class="TN_content">
      <pre>  gvascript_form.fire(eventName[, arg])</pre>

<p>used to fire event on the for instance and thus called corresponding responders and instance callback.</p>
<p><code>eventName</code>: eventName to fire without the 'on' prefix.</p>
<p><code>arg</code> argument to send over to the corresponding responder(s) and callback.</p>
<p>this method will</p>
<ol>
<li>
<p>execute the early responders set the on[eventName]</p>
</li>
<li>
<p>execute instance on[eventName] callback</p>
</li>
<li>
<p>execute the responders set the on[eventName]</p>
</li>
</ol>
<p>execution sequence will stop whenever one of the responders or callback returns <code>false</code></p>
<p>NOTE that the <b>onBeforeSubmit, onSubmit</b> events cannot be notified programatically. 
You actually need to call form.submit() for these events to be fired.</p>

    </div>
  </div>
  <div class="TN_node" id="register">
    <h3 class="TN_label">register</h3>
    <div class="TN_content">
      <pre>   gvascript_form.register(expression, eventName, handler)
   GvaScript.Form.register(form, expression, eventName, handler)</pre>

<p>tells the form to watch the <i>eventName</i> on elements that match the <i>expression</i> and to fire the corresponding <i>handler</i>.</p>
<p><code>expression</code> (String) - A css selector</p>
<p><code>eventName</code> (String) - The name of the event, in all lower case, without the "on" prefix &#x97; e.g., "click" (not "onclick").</p>
<p>A custom <b>"init"</b> event is also supported which is fired on an input that gets its value initialized with the initialization of the form.</p>
<p><code>handler</code> (Function) - handler to fire.</p>
<p>Signature</p>
<pre>  function handler(event[, newValue[, oldValue]]) {
    event.target // element being observed
  }</pre>

<p><code>newValue</code> is set for the <code>change</code> and the <code>init</code> events.</p>
<p><code>oldValue</code> is set for the <code>change</code>.</p>
<p><b>NOTE:</b> Form.Element.setValue method is wrapped in GvaScript.ProtoExtensions module to programatically fire the blur event after setting the value on the input, and hence firing the change handler if any.</p>
<p>[<i>This method can be called either as an instance method or as a generic method. If calling as a generic, pass the form HTMLElement/id in as the first argument.</i>]</p>

    </div>
  </div>
  <div class="TN_node" id="unregister">
    <h3 class="TN_label">unregister</h3>
    <div class="TN_content">
      <pre>   gvascript_form.unregister(expression[, eventName[, handler]])
   GvaScript.Form.unregister(form, expression[, eventName[, handler]])</pre>

<p>removes observers set on given <code>expression</code>.  if <code>eventName</code> is provided, will only stop observing that eventName.
if <code>handler</code> is also provided, will just stop calling this handler.</p>
<p>NOTE that the same handler signature should be used in the register method for it to work in the unregister method.</p>
<p>[<i>This method can be called either as an instance method or as a generic method. If calling as a generic, pass the form HTMLElement/id in as the first argument.</i>]</p>

    </div>
  </div>
  <div class="TN_node" id="init">
    <h3 class="TN_label">init</h3>
    <div class="TN_content">
      <pre>   gvascript_form.init(initial_tree, prefix)
   GvaScript.Form.init(form, initial_tree, prefix)</pre>

<p><code>form</code> is the id of a form (or directly the DOM element).  Optional
<code>initial_tree</code> is a javascript nested datastructure containing
initial values for fields, that will be passed to the 
<a href="#fill_from_tree">/fill_from_tree</a> method.</p>
<p>[<i>This method can be called either as an instance method or as a generic method. If calling as a generic, pass the form HTMLElement/id in as the first argument.</i>]</p>

    </div>
  </div>
  <div class="TN_node" id="to_hash">
    <h3 class="TN_label">to_hash</h3>
    <div class="TN_content">
      <pre>  var flat_hash = GvaScript.Form.to_hash(form);</pre>

<p>Inspects the contents of all fields in <code>form</code> and 
returns a flat hash of pairs (key-value).</p>
<p>[<i>This method can be called either as an instance method or as a generic method. If calling as a generic, pass the form HTMLElement/id in as the first argument.</i>]</p>

    </div>
  </div>
  <div class="TN_node" id="to_tree">
    <h3 class="TN_label">to_tree</h3>
    <div class="TN_content">
      <pre>  var tree = GvaScript.Form.to_tree(form);</pre>

<p>Inspects the contents of all fields in <code>form</code> and 
returns a data tree, were dotted names in form names



( run in 0.470 second using v1.01-cache-2.11-cpan-119454b85a5 )