Alien-GvaScript

 view release on metacpan or  search on metacpan

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

</div>
<div class="TN_leaf">
  <a class="TN_label" href="#SYNOPSIS">SYNOPSIS</a>
  <div class="TN_content"></div>
</div>
<div class="TN_node">
  <a class="TN_label" href="#DESCRIPTION">DESCRIPTION</a>
  <div class="TN_content"><div class="TN_leaf">
  <a class="TN_label" href="#Terminology">Terminology</a>
  <div class="TN_content"></div>
</div>
</div>
</div>
<div class="TN_node">
  <a class="TN_label" href="#HTML">HTML</a>
  <div class="TN_content"><div class="TN_leaf">
  <a class="TN_label" href="#Markup_of_repeat_elements">Markup of repeat elements</a>
  <div class="TN_content"></div>
</div>
<div class="TN_leaf">
  <a class="TN_label" href="#String_substitutions_within_repeat_elements">String substitutions within repeat elements</a>
  <div class="TN_content"></div>
</div>
</div>
</div>
<div class="TN_node">
  <a class="TN_label" href="#METHODS">METHODS</a>
  <div class="TN_content"><div class="TN_leaf">
  <a class="TN_label" href="#init">init</a>
  <div class="TN_content"></div>
</div>
<div class="TN_leaf">
  <a class="TN_label" href="#add">add</a>
  <div class="TN_content"></div>
</div>
<div class="TN_leaf">
  <a class="TN_label" href="#remove">remove</a>
  <div class="TN_content"></div>
</div>
</div>
</div>
<div class="TN_node">
  <a class="TN_label" href="#EVENTS">EVENTS</a>
  <div class="TN_content"><div class="TN_leaf">
  <a class="TN_label" href="#onAdd">onAdd</a>
  <div class="TN_content"></div>
</div>
<div class="TN_leaf">
  <a class="TN_label" href="#onRemove">onRemove</a>
  <div class="TN_content"></div>
</div>
</div>
</div>
<div class="TN_leaf">
  <a class="TN_label" href="#SEE_ALSO">SEE ALSO</a>
  <div class="TN_content"></div>
</div>

       </div>
     </div>
     <hr/>
   </div>
  </div>
  <div class="TN_node" id="NAME">
    <h2 class="TN_label">NAME</h2>
    <div class="TN_content">
      <p>Alien::GvaScript::Repeat - Support for repeated sections</p>

    </div>
  </div>
  <div class="TN_node" id="SYNOPSIS">
    <h2 class="TN_label">SYNOPSIS</h2>
    <div class="TN_content">
      <pre>  &lt;div repeat="foo"&gt;
    &lt;h2&gt;Foo #{foo.count}&lt;/h2&gt;
    This is the repeated foo section
    &lt;table&gt;
      &lt;tr repeat="bar"&gt;
        &lt;td&gt;Item #{bar.count}&lt;/td&gt;
        &lt;td&gt;&lt;input name="#{bar.path}.buz"&gt;&lt;/td&gt;
        &lt;td&gt;&lt;button onclick="GvaScript.Repeat.remove('#{bar.path}')"&gt;
              Remove this row
            &lt;/button&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
     &lt;button onclick="GvaScript.Repeat.add('#{foo.path}.bar')"&gt;
        Add a bar
     &lt;/button&gt;
  &lt;/div&gt;  
  &lt;button onclick="GvaScript.Repeat.add('foo')"&gt;Add a foo&lt;/button&gt;

  &lt;script&gt;
    GvaScript.Repeat.init(document.body);
  &lt;/script</pre>


    </div>
  </div>
  <div class="TN_node" id="DESCRIPTION">
    <h2 class="TN_label">DESCRIPTION</h2>
    <div class="TN_content">
      <p>This module of <i>Alien::GvaScript</i> implements a mechanism for repeated
elements within an HTML page. The main use is within forms, for
dynamic expansion of subforms, so it is quite likely that you will
want to use the <i>Alien::GvaScript::Form</i> API instead of calling the
present module directly. However, the repeat mechanism will work for
any kind of HTML element.</p>
<p>The design is partially inspired by the <code>Web Forms 2.0</code> proposal
(<a href="http://www.whatwg.org/specs/web-forms/current-work/">http://www.whatwg.org/specs/web-forms/current-work/</a>), but is 
not an attempt to implement the proposed specification: there are
some differences both in syntax and in semantics.</p>
  <div class="TN_node" id="Terminology">
    <h3 class="TN_label">Terminology</h3>
    <div class="TN_content">
      <p>At initialization stage, the DOM is inspected for finding
<i>repeat elements</i> (elements having a <code>repeat</code> attribute).
These elements are removed from the DOM and replaced
by <i>placeholders</i> (empty DOM elements, just marking where
the repetition blocks should be inserted).
Each placeholder stores a <i>template</i>, which is 
a plain string representation of the repeat element, with 



( run in 0.511 second using v1.01-cache-2.11-cpan-df04353d9ac )