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>
|
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("John");
|
var name = m.prop("John");
|
||||||
|
|
||||||
//read the value
|
//read the value
|
||||||
var a = firstName(); //a == "John"
|
var a = name(); //a == "John"
|
||||||
|
|
||||||
//set the value to `Mary`
|
//set the value to `Mary`
|
||||||
firstName("Mary"); //Mary
|
name("Mary"); //Mary
|
||||||
|
|
||||||
//read the value
|
//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>
|
<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"});
|
<pre><code class="lang-javascript">var myTask = new todo.Todo({description: "Write code"});
|
||||||
|
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -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("John");
|
var name = m.prop("John");
|
||||||
|
|
||||||
//read the value
|
//read the value
|
||||||
var a = firstName(); //a == "John"
|
var a = name(); //a == "John"
|
||||||
|
|
||||||
//set the value to `Mary`
|
//set the value to `Mary`
|
||||||
firstName("Mary"); //Mary
|
name("Mary"); //Mary
|
||||||
|
|
||||||
//read the value
|
//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>
|
<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>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue