5
<title>Example: Multiple Instances</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: Multiple Instances</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>This example shows how to work with multiple YUI instances.</p>
31
border: 1px solid black;
32
background-color: #8DD5E7;
45
YUI().use('anim', function(Y) {
46
var anim = new Y.Anim({
56
direction: 'alternate',
63
YUI().use('dd-drag', function(Y) {
64
var dd = new Y.DD.Drag({
73
<h3 id="setting-up-the-first-yui-instance">Setting up the first YUI Instance</h3>
74
<p>Here we will create our first YUI instance and tell it to load the <code>anim</code> module.</p>
76
<pre class="code prettyprint">YUI().use('anim', function(Y) {
81
<h3 id="using-animation">Using Animation</h3>
82
<p>Now let's setup a simple animation on the Node <code>#demo</code>.</p>
84
<pre class="code prettyprint">YUI().use('anim', function(Y) {
85
var anim = new Y.Anim({
86
node: '#demo',
95
direction: 'alternate',
103
<h3 id="setting-up-the-second-yui-instance">Setting up the second YUI Instance</h3>
105
<p>Here we will create our second YUI instance and tell it to load the <code>dd-drag</code> module.</p>
106
<p>Since we didn't specify the <code>anim</code> module, we will not have access to it in this instance.</p>
108
<pre class="code prettyprint">YUI().use('dd-drag', function(Y) {
113
<h3 id="making-the-node-draggable">Making the node draggable</h3>
114
<p>Now let's make the same node draggable (while it's animated).</p>
116
<pre class="code prettyprint">YUI().use('dd-drag', function(Y) {
117
var dd = new Y.DD.Drag({
118
node: '#demo'
123
<h3 id="full-example-source">Full Example Source</h3>
125
<pre class="code prettyprint"><style>
129
border: 1px solid black;
130
background-color: #8DD5E7;
138
<div id="play">
139
<div id="demo"></div>
143
YUI().use('anim', function(Y) {
144
var anim = new Y.Anim({
145
node: '#demo',
154
direction: 'alternate',
161
YUI().use('dd-drag', function(Y) {
162
var dd = new Y.DD.Drag({
163
node: '#demo'
167
</script></pre>
172
<div id="sidebar" class="yui3-u">
174
<div id="toc" class="sidebox">
176
<h2 class="no-toc">Table of Contents</h2>
182
<a href="#setting-up-the-first-yui-instance">Setting up the first YUI Instance</a>
185
<a href="#using-animation">Using Animation</a>
188
<a href="#setting-up-the-second-yui-instance">Setting up the second YUI Instance</a>
191
<a href="#making-the-node-draggable">Making the node draggable</a>
194
<a href="#full-example-source">Full Example Source</a>
202
<div class="sidebox">
204
<h2 class="no-toc">Examples</h2>
208
<ul class="examples">
211
<li data-description="Setting up a YUI Instance">
212
<a href="yui-core.html">YUI Core</a>
217
<li data-description="Working with multiple YUI instances.">
218
<a href="yui-multi.html">Multiple Instances</a>
223
<li data-description="On-demand loading of YUI and non-YUI assets">
224
<a href="yui-loader-ext.html">YUI Loader - Dynamically Adding YUI and External Modules</a>
229
<li data-description="Create Class Hierarchies with `extend`">
230
<a href="yui-extend.html">Create Class Hierarchies with `extend`</a>
235
<li data-description="Creating a composition-based class structure using `augment`">
236
<a href="yui-augment.html">Compose Classes of Objects with `augment`</a>
241
<li data-description="Add behaviors to objects or static classes with `mix`">
242
<a href="yui-mix.html">Add Behaviors to Objects with `mix`</a>
247
<li data-description="Combine data sets and create shallow copies of objects with `merge`">
248
<a href="yui-merge.html">Combine Data Sets with `merge`</a>
253
<li data-description="Check data types with the `Lang Utilities`">
254
<a href="yui-isa.html">Check Data Types with `Lang`</a>
259
<li data-description="Get information about the current user agent with `UA`">
260
<a href="yui-ua.html">Browser Detection with `UA`</a>
265
<li data-description="Working with YUI 2 in 3">
266
<a href="yui-yui2.html">Working with YUI 2 in 3</a>
271
<li data-description="Natively use YUI Gallery Modules">
272
<a href="yui-gallery.html">Natively use YUI Gallery Modules</a>
286
<script src="../assets/vendor/prettify/prettify-min.js"></script>
287
<script>prettyPrint();</script>