5
<title>Example: TabView from Existing Markup</title>
6
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Maven+Pro:400,700">
7
<link rel="stylesheet" href="../../build/cssgrids/grids-min.css">
8
<link rel="stylesheet" href="../assets/css/main.css">
9
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
10
<script src="../../build/yui/yui-min.js"></script>
15
<h1>Example: TabView from Existing Markup</h1>
20
<div class="yui3-u-3-4">
22
<div class="content"><div class="intro">
23
<p>This example shows how to create a <code>TabView</code> widget from existing HTML on the page.</p>
26
<div class="example yui3-skin-sam">
29
<li><a href="#foo">foo</a></li>
30
<li><a href="#bar">bar</a></li>
31
<li><a href="#baz">baz</a></li>
46
<script type="text/javascript">
47
YUI().use('tabview', function(Y) {
48
var tabview = new Y.TabView({srcNode:'#demo'});
55
<h2>Creating A TabView From Existing Markup</h2>
57
<p>A <code>TabView</code> can be created easily from existing markup, supporting a progressive enhancement approach to development.</p>
61
<p>The only markup requirements are an unordered list of items and a corresponding group of divs.</p>
63
<pre class="code prettyprint"><div id="demo">
65
<li><a href="#foo">foo</a></li>
66
<li><a href="#bar">bar</a></li>
67
<li><a href="#baz">baz</a></li>
70
<div id="foo">
71
<p>foo content</p>
73
<div id="bar">
74
<p>bar content</p>
76
<div id="baz">
77
<p>baz content</p>
80
</div></pre>
83
<h3>The JavaScript</h3>
85
<p><code>TabView</code> extends <code>Widget</code>, and the <code>srcNode</code>
86
becomes the <code>contentBox</code>. This is the
87
minimal requirement to create a <code>Tabview</code> instance for the markup,
88
and can be assigned using a selector. Calling render enlivens the <code>TabView
89
</code> making it usable.</p>
91
<pre class="code prettyprint">var tabview = new Y.TabView({srcNode:'#demo'});
92
tabview.render();</pre>
96
<h2>Complete Example Source</h2>
97
<pre class="code prettyprint"><div id="demo">
99
<li><a href="#foo">foo</a></li>
100
<li><a href="#bar">bar</a></li>
101
<li><a href="#baz">baz</a></li>
104
<div id="foo">
105
<p>foo content</p>
107
<div id="bar">
108
<p>bar content</p>
110
<div id="baz">
111
<p>baz content</p>
116
<script type="text/javascript">
117
YUI().use('tabview', function(Y) {
118
var tabview = new Y.TabView({srcNode:'#demo'});
121
</script></pre>
127
<div class="yui3-u-1-4">
128
<div class="sidebar">
132
<div class="sidebox">
134
<h2 class="no-toc">Examples</h2>
138
<ul class="examples">
141
<li data-description="This example shows how to create a TabView wigdet from existing HTML.">
142
<a href="tabview-basic.html">TabView from Existing Markup</a>
147
<li data-description="This example shows how to create a TabView wigdet from JavaScript.">
148
<a href="tabview-fromjs.html">Dynamic TabView from JavaScript</a>
153
<li data-description="This example shows how to add and remove Tabs.">
154
<a href="tabview-add-remove.html">Adding and Removing Tabs</a>
159
<li data-description="This example shows how to load tab content remotely using a YQL plugin.">
160
<a href="tabview-yql.html">Loading Tab Content</a>
172
<div class="sidebox">
174
<h2 class="no-toc">Examples That Use This Component</h2>
178
<ul class="examples">
189
<li data-description="Demonstrates how to add browser history support to a TabView widget using the History Utility.">
190
<a href="../history/history-tabview.html">History + TabView</a>
203
<script src="../assets/vendor/prettify/prettify-min.js"></script>
204
<script>prettyPrint();</script>