mirror of
https://github.com/JeremyLikness/vanillajs-deck
synced 2024-12-04 19:27:37 +00:00
Databinding slide
This commit is contained in:
parent
c6da0a7650
commit
bf40a6f00c
@ -15,4 +15,5 @@ app.js
|
|||||||
-- keyhandler.js
|
-- keyhandler.js
|
||||||
.. navigator.js ⤴
|
.. navigator.js ⤴
|
||||||
</pre>
|
</pre>
|
||||||
<h2 class="appear">Inception Demo</h2>
|
<h2 class="appear">Inception Demo</h2>
|
||||||
|
<next-slide>200-data-binding</next-slide>
|
@ -1,14 +1,16 @@
|
|||||||
<title>Data-Binding Example 1</title>
|
<title>Databinding</title>
|
||||||
<h1>Data-Binding Example</h1>
|
<h1>Databinding Examples</h1>
|
||||||
|
<h2 class="anim-spin"><—></h2>
|
||||||
<label for="first"><div>Number:</div><input type="text" id="first" data-bind="n1"/></label>
|
<label for="first"><div>Number:</div><input type="text" id="first" data-bind="n1"/></label>
|
||||||
<label for="second"><div>Multiplied by Number:</div><input type="text" id="second" data-bind="n2"/></label>
|
<label for="second"><div>Multiplied by Number:</div><input type="text" id="second" data-bind="n2"/></label>
|
||||||
<label for="result"><div>Result:</div><input type="text" id="result" data-bind="result" disabled/></label>
|
<label for="result"><div>Result:</div><input type="text" id="result" data-bind="result" disabled/></label>
|
||||||
<label for="firstName"><div>First Name:</div><input type="text" id="firstName" data-bind="first"/></label>
|
<label for="firstName"><div>First Name:</div><input type="text" id="firstName" data-bind="first"/></label>
|
||||||
<label for="lastName"><div>Last Name:</div><input type="text" id="lastName" data-bind="last"/></label>
|
<label for="lastName"><div>Last Name:</div><input type="text" id="lastName" data-bind="last"/></label>
|
||||||
<label for="fullName"><div>Full Name:</div><input type="text" id="fullName" data-bind="full" disabled/></label>
|
<label for="fullName"><div>Full Name:</div><input type="text" id="fullName" data-bind="full" disabled/></label>
|
||||||
|
<label for="backwards"><div>Backwards:</div><input type="text" id="backwards" data-bind="back" disabled/></label>
|
||||||
<br/>
|
<br/>
|
||||||
<ul>
|
<ul>
|
||||||
<li repeat="list" class="appear">{{item.idx}} — {{item.value}}</li>
|
<li repeat="list">{{item.idx}} — {{item.value}}</li>
|
||||||
</ul>
|
</ul>
|
||||||
<script>
|
<script>
|
||||||
this.list = [{idx: 0, value:"one"}, {idx: 1, value:"two"}, {idx: 2, value:"three"}];
|
this.list = [{idx: 0, value:"one"}, {idx: 1, value:"two"}, {idx: 2, value:"three"}];
|
||||||
@ -23,5 +25,7 @@
|
|||||||
this.last = last;
|
this.last = last;
|
||||||
// computed
|
// computed
|
||||||
this.result = this.computed(() => n1.value*n2.value, [n1, n2]);
|
this.result = this.computed(() => n1.value*n2.value, [n1, n2]);
|
||||||
this.full = this.computed(() => `${first.value} ${last.value}`.trim(), [first, last]);
|
const full = this.computed(() => `${first.value} ${last.value}`.trim(), [first, last]);
|
||||||
|
this.full = full;
|
||||||
|
this.back = this.computed(() => `${full.value.split('').reverse().join('')}`, [full]);
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue
Block a user