5
<title>Example: Simple Sortable List</title>
6
<link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
7
<link rel="stylesheet" href="../assets/css/main.css">
8
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
9
<script src="../../build/yui/yui-min.js"></script>
14
<h1>Example: Simple Sortable List</h1>
17
<a href="#toc" class="jump">Jump to Table of Contents</a>
21
<div id="main" class="yui3-u">
22
<div class="content"><div class="intro">
23
<p>Making a simple sortable list.</p>
29
list-style-type: none;
32
border: 1px solid black;
34
background-color: #8DD5E7;
57
YUI().use('sortable', function(Y) {
58
var sortable = new Y.Sortable({
72
<h3 id="setting-up-the-list">Setting Up the List</h3>
73
<p>First we need to create the HTML structure for the list. Since <code>Sortable</code> uses <code>Y.DD.Delegate</code>, we need to set up a delegation container (<code>#demo</code>) and the list items (<code>li</code>).</p>
75
<pre class="code prettyprint"><div id="demo">
77
<li>Item #1</li>
78
<li>Item #2</li>
79
<li>Item #3</li>
80
<li>Item #4</li>
81
<li>Item #5</li>
82
<li>Item #6</li>
83
<li>Item #7</li>
84
<li>Item #8</li>
85
<li>Item #9</li>
86
<li>Item #10</li>
88
</div></pre>
91
<p>Now we give the list some CSS to make it visible.</p>
93
<pre class="code prettyprint">#demo li {
94
list-style-type: none;
97
border: 1px solid black;
99
background-color: #8DD5E7;
104
<h3 id="setting-up-the-yui-instance">Setting Up the YUI Instance</h3>
105
<p>Now we need to create our YUI instance and tell it to load the <code>sortable</code> module.</p>
107
<pre class="code prettyprint">YUI().use('sortable'</pre>
111
<h3 id="making-the-list-draggable">Making the List Draggable</h3>
112
<p>Now that we have a YUI instance with the <code>sortable</code> module, we need to instantiate the <code>Sortable</code> instance on the list.</p>
114
<pre class="code prettyprint">YUI().use('sortable', function(Y) {
115
var sortable = new Y.Sortable({
116
container: '#demo',
117
nodes: 'li',
118
opacity: '.1'
125
<div id="sidebar" class="yui3-u">
127
<div id="toc" class="sidebox">
129
<h2 class="no-toc">Table of Contents</h2>
135
<a href="#setting-up-the-list">Setting Up the List</a>
138
<a href="#setting-up-the-yui-instance">Setting Up the YUI Instance</a>
141
<a href="#making-the-list-draggable">Making the List Draggable</a>
149
<div class="sidebox">
151
<h2 class="no-toc">Examples</h2>
155
<ul class="examples">
158
<li data-description="Create a simple sortable list.">
159
<a href="simple-sortable.html">Simple Sortable List</a>
164
<li data-description="Sortable list example with floated nodes.">
165
<a href="sortable-float.html">Floated List</a>
170
<li data-description="Multiple Sortable Lists that are separate from one another.">
171
<a href="sortable-multi.html">Multiple Lists</a>
176
<li data-description="Multiple Sortable Lists that are fully joined together.">
177
<a href="sortable-multi-full.html">Multiple Lists - Full Join</a>
182
<li data-description="Multiple Sortable Lists that are outer joined together.">
183
<a href="sortable-multi-out.html">Multiple Lists - Outer Join</a>
188
<li data-description="Multiple Sortable Lists that are inner joined together.">
189
<a href="sortable-multi-in.html">Multiple Lists - Inner Join</a>
203
<script src="../assets/vendor/prettify/prettify-min.js"></script>
204
<script>prettyPrint();</script>