-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
83 lines (69 loc) · 2.78 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!doctype html>
<html lang='en-GB'>
<head>
<meta charset='utf-8'>
<title>Ractive.js select2 decorator plugin</title>
<!-- CSS -->
<link href='http://fonts.googleapis.com/css?family=Voltaire' rel='stylesheet' type='text/css'>
<link rel='stylesheet' href='demo/main.css'>
<link rel='stylesheet' href='http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.css'>
</head>
<body>
<a class='forkme' href='https://github.com/prezent/ractive-decorators-select2'>Fork me on GitHub</a>
<header>
<h1>Ractive.js Select2 decorator plugin</h1>
<p class='strap'>
<span class='download'>download: <a href='https://github.com/prezent/ractive-decorators-select2'>ractive-decorators-select2.js</a></span>
<span class='more-plugins'>more plugins at <a href='http://ractivejs.org/plugins'>ractivejs.org/plugins</a></span>
</p>
</header>
<main>
<p>Integrate <a href='http://ivaynberg.github.io/select2/'>Select2</a> with Ractive, including two-way binding.</p>
<p>In order to pass options to the select2 constructor, add an options object to the decorator <tt>type</tt> property as seen in
the demo below.</p>
<div id='demo' class='clearfix'></div>
<pre id='demo-template-view' class='prettyprint lang-html'></pre>
<pre id='demo-code-view' class='prettyprint lang-js'></pre>
</main>
<footer>
<p>Copyright © 2014 <a href="http://www.prezent.nl">Prezent Internet B.V.</a> Licensed MIT</p>
</footer>
<!-- Demo template -->
<script id='demo-template' type='text/ractive'>
<select decorator='select2:demo' value='{{selected}}'>
{{#options}}
<option value='{{.}}'>{{.}}</option>
{{/options}}
</select>
<button on-click='reset-data'>Reset (two-way binding)</button>
<p>Selected option: {{selected}}</p>
</script>
<!-- Dependencies -->
<script src='http://code.jquery.com/jquery-2.1.1.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.js'></script>
<script src='http://cdn.ractivejs.org/latest/ractive.js'></script>
<script src='ractive-decorators-select2.js'></script>
<!-- Demo code -->
<script id='demo-code'>
// define select2 options
Ractive.decorators.select2.type.demo = function (node) {
return {
width: '25%'
}
};
ractive = new Ractive({
el: 'demo',
template: '#demo-template',
data: {
selected: 'one',
options: [ 'one', 'two', 'three', 'four', 'five', 'six' ]
}
});
ractive.on('reset-data', function(event) {
this.set('selected', 'one');
});
</script>
<script src='demo/prettify.js'></script>
<script src='demo/demo.js'></script>
</body>
</html>