Oops. Modified archives by accident.
This commit is contained in:
parent
44f6a9a64d
commit
1053b70d3e
2 changed files with 10 additions and 10 deletions
|
|
@ -81,16 +81,16 @@ todo.Todo = function(data) {
|
|||
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>
|
||||
<pre><code class="lang-javascript">//define a getter-setter with initial value `John`
|
||||
var firstName = m.prop("John");
|
||||
var name = m.prop("John");
|
||||
|
||||
//read the value
|
||||
var a = firstName(); //a == "John"
|
||||
var a = name(); //a == "John"
|
||||
|
||||
//set the value to `Mary`
|
||||
firstName("Mary"); //Mary
|
||||
name("Mary"); //Mary
|
||||
|
||||
//read the value
|
||||
var b = firstName(); //b == "Mary"</code></pre>
|
||||
var b = name(); //b == "Mary"</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>
|
||||
<pre><code class="lang-javascript">var myTask = new todo.Todo({description: "Write code"});
|
||||
|
||||
|
|
@ -442,4 +442,4 @@ this.description = function(value) {
|
|||
</footer>
|
||||
<script src="lib/prism/prism.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
@ -64,16 +64,16 @@
|
|||
<hr>
|
||||
<h3 id="usage">Usage</h3>
|
||||
<pre><code class="lang-javascript">//define a getter-setter with initial value `John`
|
||||
var firstName = m.prop("John");
|
||||
var name = m.prop("John");
|
||||
|
||||
//read the value
|
||||
var a = firstName(); //a == "John"
|
||||
var a = name(); //a == "John"
|
||||
|
||||
//set the value to `Mary`
|
||||
firstName("Mary"); //Mary
|
||||
name("Mary"); //Mary
|
||||
|
||||
//read the value
|
||||
var b = firstName(); //b == "Mary"</code></pre>
|
||||
var b = name(); //b == "Mary"</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>
|
||||
<pre><code class="lang-javascript">//a contrived example of bi-directional data binding
|
||||
var user = {
|
||||
|
|
@ -137,4 +137,4 @@ where:
|
|||
</footer>
|
||||
<script src="lib/prism/prism.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue