1 | <p>
|
---|
2 | <ul class="UIAPIPlugin-toc">
|
---|
3 | <li><a href="#overview">Overview</a></li>
|
---|
4 | <li><a href="#options">Options</a></li>
|
---|
5 | <li><a href="#events">Events</a></li>
|
---|
6 | <li><a href="#methods">Methods</a></li>
|
---|
7 | <li><a href="#theming">Theming</a></li>
|
---|
8 | </ul>
|
---|
9 | <div class="UIAPIPlugin">
|
---|
10 | <h1>jQuery UI Button</h1>
|
---|
11 | <div id="overview">
|
---|
12 | <h2 class="top-header">Overview</h2>
|
---|
13 | <div id="overview-main">
|
---|
14 | Button enhances standard form elements like button, input of type submit or reset or anchors to themable buttons with appropiate mouseover and active styles.
|
---|
15 | </p><p>In addition to basic push buttons, radio buttons and checkboxes (inputs of type radio and checkbox) can be converted to buttons: Their associated label is styled to appear as the button, while the underlying input is updated on click.
|
---|
16 | </p>
|
---|
17 | Buttons can be grouped using the buttonSet method, which should be always applied for radio buttons.
|
---|
18 | </div>
|
---|
19 | <div id="overview-dependencies">
|
---|
20 | <h3>Dependencies</h3>
|
---|
21 | <ul>
|
---|
22 | <li>UI Core</li>
|
---|
23 | <li>UI Widget</li>
|
---|
24 | </ul>
|
---|
25 | </div>
|
---|
26 | <div id="overview-example">
|
---|
27 | <h3>Example</h3>
|
---|
28 | <div id="overview-example" class="example">
|
---|
29 | <ul><li><a href="#demo"><span>Demo</span></a></li><li><a href="#source"><span>View Source</span></a></li></ul>
|
---|
30 | <p><div id="demo" class="tabs-container" rel="300">
|
---|
31 | A simple jQuery UI Button.<br />
|
---|
32 | </p>
|
---|
33 | <pre>$("button").button();
|
---|
34 | </pre>
|
---|
35 | <p></div><div id="source" class="tabs-container">
|
---|
36 | </p>
|
---|
37 | <pre><!DOCTYPE html>
|
---|
38 | <html>
|
---|
39 | <head>
|
---|
40 | <link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
|
---|
41 | <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
|
---|
42 | <script type="text/javascript" src="http://jqueryui.com/latest/ui/jquery.ui.core.js"></script>
|
---|
43 | <script type="text/javascript" src="http://jqueryui.com/latest/ui/jquery.ui.widget.js"></script>
|
---|
44 | <script type="text/javascript" src="http://jqueryui.com/latest/ui/jquery.ui.button.js"></script>
|
---|
45 | <script type="text/javascript">
|
---|
46 | $(document).ready(function(){
|
---|
47 | $("button").button();
|
---|
48 | });
|
---|
49 | </script>
|
---|
50 | </head>
|
---|
51 | <body style="font-size:62.5%;">
|
---|
52 |
|
---|
53 | <button>Button label</button>
|
---|
54 |
|
---|
55 | </body>
|
---|
56 | </html>
|
---|
57 | </pre>
|
---|
58 | <p></div>
|
---|
59 | </p><p></div>
|
---|
60 | </div>
|
---|
61 | </div>
|
---|
62 | <div id="options">
|
---|
63 | <h2 class="top-header">Options</h2>
|
---|
64 | <ul class="options-list">
|
---|
65 |
|
---|
66 | <li class="option" id="option-text">
|
---|
67 | <div class="option-header">
|
---|
68 | <h3 class="option-name"><a href="#option-text">text</a></h3>
|
---|
69 | <dl>
|
---|
70 | <dt class="option-type-label">Type:</dt>
|
---|
71 | <dd class="option-type">Boolean</dd>
|
---|
72 |
|
---|
73 | <dt class="option-default-label">Default:</dt>
|
---|
74 | <dd class="option-default">true</dd>
|
---|
75 |
|
---|
76 | </dl>
|
---|
77 | </div>
|
---|
78 | <div class="option-description">
|
---|
79 | <p>Whether to show any text - when set to false (display no text), icons (see icons option) must be enabled, otherwise it'll be ignored.</p>
|
---|
80 | </div>
|
---|
81 | <div class="option-examples">
|
---|
82 | <h4>Code examples</h4>
|
---|
83 | <dl class="option-examples-list">
|
---|
84 |
|
---|
85 | <dt>
|
---|
86 | Initialize a button with the <code>text</code> option specified.
|
---|
87 | </dt>
|
---|
88 | <dd>
|
---|
89 | <pre><code>$('.selector').button({ text: false });</code></pre>
|
---|
90 | </dd>
|
---|
91 |
|
---|
92 |
|
---|
93 | <dt>
|
---|
94 | Get or set the <code>text</code> option, after init.
|
---|
95 | </dt>
|
---|
96 | <dd>
|
---|
97 | <pre><code>//getter
|
---|
98 | var text = $('.selector').button('option', 'text');
|
---|
99 | //setter
|
---|
100 | $('.selector').button('option', 'text', false);</code></pre>
|
---|
101 | </dd>
|
---|
102 |
|
---|
103 | </dl>
|
---|
104 | </div>
|
---|
105 | </li>
|
---|
106 |
|
---|
107 |
|
---|
108 | <li class="option" id="option-icons">
|
---|
109 | <div class="option-header">
|
---|
110 | <h3 class="option-name"><a href="#option-icons">icons</a></h3>
|
---|
111 | <dl>
|
---|
112 | <dt class="option-type-label">Type:</dt>
|
---|
113 | <dd class="option-type">Options</dd>
|
---|
114 |
|
---|
115 | <dt class="option-default-label">Default:</dt>
|
---|
116 | <dd class="option-default">{ primary: null, secondary: null }</dd>
|
---|
117 |
|
---|
118 | </dl>
|
---|
119 | </div>
|
---|
120 | <div class="option-description">
|
---|
121 | <p>Icons to display, with or without text (see text option). The primary icon is displayed on the left of the label text, the secondary on the right. Value for the primary and secondary properties must be a classname (String), eg. "ui-icon-gear". For using only a primary icon: icons: {primary:'ui-icon-locked'}. For using both primary and secondary icon: icons: {primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'}</p>
|
---|
122 | </div>
|
---|
123 | <div class="option-examples">
|
---|
124 | <h4>Code examples</h4>
|
---|
125 | <dl class="option-examples-list">
|
---|
126 |
|
---|
127 | <dt>
|
---|
128 | Initialize a button with the <code>icons</code> option specified.
|
---|
129 | </dt>
|
---|
130 | <dd>
|
---|
131 | <pre><code>$('.selector').button({ icons: {primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'} });</code></pre>
|
---|
132 | </dd>
|
---|
133 |
|
---|
134 |
|
---|
135 | <dt>
|
---|
136 | Get or set the <code>icons</code> option, after init.
|
---|
137 | </dt>
|
---|
138 | <dd>
|
---|
139 | <pre><code>//getter
|
---|
140 | var icons = $('.selector').button('option', 'icons');
|
---|
141 | //setter
|
---|
142 | $('.selector').button('option', 'icons', {primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'});</code></pre>
|
---|
143 | </dd>
|
---|
144 |
|
---|
145 | </dl>
|
---|
146 | </div>
|
---|
147 | </li>
|
---|
148 |
|
---|
149 |
|
---|
150 | <li class="option" id="option-label">
|
---|
151 | <div class="option-header">
|
---|
152 | <h3 class="option-name"><a href="#option-label">label</a></h3>
|
---|
153 | <dl>
|
---|
154 | <dt class="option-type-label">Type:</dt>
|
---|
155 | <dd class="option-type">String</dd>
|
---|
156 |
|
---|
157 | <dt class="option-default-label">Default:</dt>
|
---|
158 | <dd class="option-default">HTML content of the button, or value attribute</dd>
|
---|
159 |
|
---|
160 | </dl>
|
---|
161 | </div>
|
---|
162 | <div class="option-description">
|
---|
163 | <p>Text to show on the button. When not specified (null), the element's html content is used, or its value attribute when it's an input element of type submit or reset; or the html content of the associated label element if its an input of type radio or checkbox</p>
|
---|
164 | </div>
|
---|
165 | <div class="option-examples">
|
---|
166 | <h4>Code examples</h4>
|
---|
167 | <dl class="option-examples-list">
|
---|
168 |
|
---|
169 | <dt>
|
---|
170 | Initialize a button with the <code>label</code> option specified.
|
---|
171 | </dt>
|
---|
172 | <dd>
|
---|
173 | <pre><code>$('.selector').button({ label: "custom label" });</code></pre>
|
---|
174 | </dd>
|
---|
175 |
|
---|
176 |
|
---|
177 | <dt>
|
---|
178 | Get or set the <code>label</code> option, after init.
|
---|
179 | </dt>
|
---|
180 | <dd>
|
---|
181 | <pre><code>//getter
|
---|
182 | var label = $('.selector').button('option', 'label');
|
---|
183 | //setter
|
---|
184 | $('.selector').button('option', 'label', "custom label");</code></pre>
|
---|
185 | </dd>
|
---|
186 |
|
---|
187 | </dl>
|
---|
188 | </div>
|
---|
189 | </li>
|
---|
190 |
|
---|
191 | </ul>
|
---|
192 | </div>
|
---|
193 | <div id="events">
|
---|
194 | <h2 class="top-header">Events</h2>
|
---|
195 | <ul class="events-list">
|
---|
196 |
|
---|
197 | <li class="event" id="event-click">
|
---|
198 | <div class="event-header">
|
---|
199 | <h3 class="event-name"><a href="#event-click">click</a></h3>
|
---|
200 | <dl>
|
---|
201 | <dt class="event-type-label">Type:</dt>
|
---|
202 | <dd class="event-type">click</dd>
|
---|
203 | </dl>
|
---|
204 | </div>
|
---|
205 | <div class="event-description">
|
---|
206 | <p>Usually the native click event, with the exception of keyboard-triggered click with the space key on anchors and generally on checkboxes and radio buttons.</p>
|
---|
207 | </div>
|
---|
208 | <div class="event-examples">
|
---|
209 | <h4>Code examples</h4>
|
---|
210 | <dl class="event-examples-list">
|
---|
211 |
|
---|
212 | <dt>
|
---|
213 | Supply a callback function to handle the <code>click</code> event as an init option.
|
---|
214 | </dt>
|
---|
215 | <dd>
|
---|
216 | <pre><code>$('.selector').button({
|
---|
217 | click: function(event, ui) { ... }
|
---|
218 | });</code></pre>
|
---|
219 | </dd>
|
---|
220 |
|
---|
221 |
|
---|
222 | <dt>
|
---|
223 | Bind to the <code>click</code> event by type: <code>click</code>.
|
---|
224 | </dt>
|
---|
225 | <dd>
|
---|
226 | <pre><code>$('.selector').bind('click', function(event, ui) {
|
---|
227 | ...
|
---|
228 | });</code></pre>
|
---|
229 | </dd>
|
---|
230 |
|
---|
231 | </dl>
|
---|
232 | </div>
|
---|
233 | </li>
|
---|
234 |
|
---|
235 | </ul>
|
---|
236 | </div>
|
---|
237 | <div id="methods">
|
---|
238 | <h2 class="top-header">Methods</h2>
|
---|
239 | <ul class="methods-list">
|
---|
240 |
|
---|
241 | <li class="method" id="method-destroy">
|
---|
242 | <div class="method-header">
|
---|
243 | <h3 class="method-name"><a href="#method-destroy">destroy</a></h3>
|
---|
244 | <dl>
|
---|
245 | <dt class="method-signature-label">Signature:</dt>
|
---|
246 | <dd class="method-signature">.button( 'destroy'
|
---|
247 |
|
---|
248 |
|
---|
249 |
|
---|
250 |
|
---|
251 |
|
---|
252 |
|
---|
253 |
|
---|
254 | )</dd>
|
---|
255 | </dl>
|
---|
256 | </div>
|
---|
257 | <div class="method-description">
|
---|
258 | <p>Remove the button functionality completely. This will return the element back to its pre-init state.</p>
|
---|
259 | </div>
|
---|
260 | </li>
|
---|
261 |
|
---|
262 |
|
---|
263 | <li class="method" id="method-disable">
|
---|
264 | <div class="method-header">
|
---|
265 | <h3 class="method-name"><a href="#method-disable">disable</a></h3>
|
---|
266 | <dl>
|
---|
267 | <dt class="method-signature-label">Signature:</dt>
|
---|
268 | <dd class="method-signature">.button( 'disable'
|
---|
269 |
|
---|
270 |
|
---|
271 |
|
---|
272 |
|
---|
273 |
|
---|
274 |
|
---|
275 |
|
---|
276 | )</dd>
|
---|
277 | </dl>
|
---|
278 | </div>
|
---|
279 | <div class="method-description">
|
---|
280 | <p>Disable the button.</p>
|
---|
281 | </div>
|
---|
282 | </li>
|
---|
283 |
|
---|
284 |
|
---|
285 | <li class="method" id="method-enable">
|
---|
286 | <div class="method-header">
|
---|
287 | <h3 class="method-name"><a href="#method-enable">enable</a></h3>
|
---|
288 | <dl>
|
---|
289 | <dt class="method-signature-label">Signature:</dt>
|
---|
290 | <dd class="method-signature">.button( 'enable'
|
---|
291 |
|
---|
292 |
|
---|
293 |
|
---|
294 |
|
---|
295 |
|
---|
296 |
|
---|
297 |
|
---|
298 | )</dd>
|
---|
299 | </dl>
|
---|
300 | </div>
|
---|
301 | <div class="method-description">
|
---|
302 | <p>Enable the button.</p>
|
---|
303 | </div>
|
---|
304 | </li>
|
---|
305 |
|
---|
306 |
|
---|
307 | <li class="method" id="method-option">
|
---|
308 | <div class="method-header">
|
---|
309 | <h3 class="method-name"><a href="#method-option">option</a></h3>
|
---|
310 | <dl>
|
---|
311 | <dt class="method-signature-label">Signature:</dt>
|
---|
312 | <dd class="method-signature">.button( 'option'
|
---|
313 |
|
---|
314 | , optionName
|
---|
315 |
|
---|
316 | , <span class="optional">[</span>value<span class="optional">] </span>
|
---|
317 |
|
---|
318 |
|
---|
319 |
|
---|
320 | )</dd>
|
---|
321 | </dl>
|
---|
322 | </div>
|
---|
323 | <div class="method-description">
|
---|
324 | <p>Get or set any button option. If no value is specified, will act as a getter.</p>
|
---|
325 | </div>
|
---|
326 | </li>
|
---|
327 |
|
---|
328 |
|
---|
329 | </ul>
|
---|
330 | </div>
|
---|
331 | <div id="theming">
|
---|
332 | <h2 class="top-header">Theming</h2>
|
---|
333 | <p>The jQuery UI Button plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain.
|
---|
334 | </p>
|
---|
335 | <p>If a deeper level of customization is needed, there are widget-specific classes referenced within the ui.button.css stylesheet that can be modified. These classes are highlighed in bold below.
|
---|
336 | </p>
|
---|
337 |
|
---|
338 | <h3>Sample markup with jQuery UI CSS Framework classes</h3>
|
---|
339 | <button class="<strong>ui-button</strong> ui-button-text-only ui-widget ui-state-default ui-corner-all"/><span class="ui-button-text">Button Label</span></button>
|
---|
340 | <p class="theme-note">
|
---|
341 | <strong>
|
---|
342 | Note: This is a sample of markup generated by the button plugin, not markup you should use to create a button. The only markup needed for that is <button>Button Label</button>.
|
---|
343 | </strong>
|
---|
344 | </p>
|
---|
345 |
|
---|
346 | </div>
|
---|
347 | </div>
|
---|
348 |
|
---|
349 | </p><!--
|
---|
350 | Pre-expand include size: 16142 bytes
|
---|
351 | Post-expand include size: 22124 bytes
|
---|
352 | Template argument size: 11318 bytes
|
---|
353 | Maximum: 2097152 bytes
|
---|
354 | -->
|
---|
355 |
|
---|
356 | <!-- Saved in parser cache with key jqdocs_docs:pcache:idhash:3767-1!1!0!!en!2 and timestamp 20100128052926 -->
|
---|