Ainm

Automatic Input Name Model

Ainm is a small JavaScript library that automatically creates a client side model with two-way binding based on input element names. In order to display a value in another HTML element use the attribute data-ainm with the name of the input element as the value. (As it happens “ainm” means “name” in Irish.)

Code Example

HTML

<p>
  <input type="text" name="username">
</p>
<p>
  Hello
  <span data-ainm="username"></span>
</p>
<p>
  Today is
  <span data-ainm="weekday"></span>
</p>

JavaScript

var model = new Ainm();
model.set( 'weekday', 'thursday' );

Make sure you load ainm.js before use, for instance by putting the following at the end of the HTML body element:

<script type="text/javascript"
  src="ainm.js"></script>

The Ainm source code is licensed under the MIT License.