-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
65 lines (60 loc) · 1.61 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!-- Template to load -->
<script type="text/stache" id="demo" can-autorender>
<can-import from="bit-autocomplete"/><bit-autocomplete
model="{Search}"
selected-item="{selectedItem}"
validated="{validated}">
</bit-autocomplete>
<p>
{{#validated}}
You selected {{selectedItem.label}}.
{{else}}
Do a search then select an item...
{{/validated}}
</p>
</script>
<!-- Loading Script -->
<script src="./node_modules/steal/steal.js" id="demo_source" main="can/view/autorender/">
import $ from "jquery";
import can from "can";
import "can/util/fixture/";
var fruits = [
{ label: "Granny Smith Apple"},
{ label: "McIntosh Apple"},
{ label: "Fuji Apple"},
{ label: "Red Delicious Apple"},
{ label: "Pink Lady Apple"},
{ label: "Golden Delcicious Apple"},
{ label: "Gala Apple"},
{ label: "Strawberry"},
{ label: "Orange"},
{ label: "Plum"},
{ label: "Blueberry"},
{ label: "Pear"},
{ label: "Peach"},
{ label: "Tomato"},
{ label: "Fig"},
{ label: "Watermelon"},
{ label: "Melon"},
{ label: "Sprite Melon"},
{ label: "Lemon"}
];
can.fixture('GET /test', function(req) {
var filtered = fruits.filter(function(item) {
return item.label.toLowerCase().indexOf(req.data.label.toLowerCase()) > -1;
});
return filtered;
});
var Search = can.Model.extend({
findAll: "GET /test"
},{});
$("#demo").viewModel().attr({
Search: Search,
selectedItem: {},
valdated: false
});
</script>
<script>
window.DEMO_HTML = document.getElementById("demo").innerHTML.replace('<can-import from="bit-autocomplete"/>', '');
window.DEMO_SOURCE = document.getElementById("demo_source").innerHTML;
</script>