Oops. Modified archives by accident.

This commit is contained in:
Barney 2014-11-07 10:26:00 +00:00
parent 44f6a9a64d
commit 1053b70d3e
2 changed files with 10 additions and 10 deletions

View file

@ -81,16 +81,16 @@ todo.Todo = function(data) {
todo.TodoList = Array;</code></pre> todo.TodoList = Array;</code></pre>
<p><a href="mithril.prop.html"><code>m.prop</code></a> is simply a factory for a getter-setter function. Getter-setters work like this:</p> <p><a href="mithril.prop.html"><code>m.prop</code></a> is simply a factory for a getter-setter function. Getter-setters work like this:</p>
<pre><code class="lang-javascript">//define a getter-setter with initial value `John` <pre><code class="lang-javascript">//define a getter-setter with initial value `John`
var firstName = m.prop(&quot;John&quot;); var name = m.prop(&quot;John&quot;);
//read the value //read the value
var a = firstName(); //a == &quot;John&quot; var a = name(); //a == &quot;John&quot;
//set the value to `Mary` //set the value to `Mary`
firstName(&quot;Mary&quot;); //Mary name(&quot;Mary&quot;); //Mary
//read the value //read the value
var b = firstName(); //b == &quot;Mary&quot;</code></pre> var b = name(); //b == &quot;Mary&quot;</code></pre>
<p>Note that the <code>Todo</code> and <code>TodoList</code> classes we defined above are plain vanilla Javascript constructors. They can be initialized and used like this:</p> <p>Note that the <code>Todo</code> and <code>TodoList</code> classes we defined above are plain vanilla Javascript constructors. They can be initialized and used like this:</p>
<pre><code class="lang-javascript">var myTask = new todo.Todo({description: &quot;Write code&quot;}); <pre><code class="lang-javascript">var myTask = new todo.Todo({description: &quot;Write code&quot;});
@ -442,4 +442,4 @@ this.description = function(value) {
</footer> </footer>
<script src="lib/prism/prism.js"></script> <script src="lib/prism/prism.js"></script>
</body> </body>
</html> </html>

View file

@ -64,16 +64,16 @@
<hr> <hr>
<h3 id="usage">Usage</h3> <h3 id="usage">Usage</h3>
<pre><code class="lang-javascript">//define a getter-setter with initial value `John` <pre><code class="lang-javascript">//define a getter-setter with initial value `John`
var firstName = m.prop(&quot;John&quot;); var name = m.prop(&quot;John&quot;);
//read the value //read the value
var a = firstName(); //a == &quot;John&quot; var a = name(); //a == &quot;John&quot;
//set the value to `Mary` //set the value to `Mary`
firstName(&quot;Mary&quot;); //Mary name(&quot;Mary&quot;); //Mary
//read the value //read the value
var b = firstName(); //b == &quot;Mary&quot;</code></pre> var b = name(); //b == &quot;Mary&quot;</code></pre>
<p>It can be used in conjunction with <a href="mithril.withattr.html"><code>m.withAttr</code></a> to implement data binding in the view-to-model direction and to provide uniform data access for model entity properties.</p> <p>It can be used in conjunction with <a href="mithril.withattr.html"><code>m.withAttr</code></a> to implement data binding in the view-to-model direction and to provide uniform data access for model entity properties.</p>
<pre><code class="lang-javascript">//a contrived example of bi-directional data binding <pre><code class="lang-javascript">//a contrived example of bi-directional data binding
var user = { var user = {
@ -137,4 +137,4 @@ where:
</footer> </footer>
<script src="lib/prism/prism.js"></script> <script src="lib/prism/prism.js"></script>
</body> </body>
</html> </html>