Skip to content

Commit 821946a

Browse files
committed
jquery.widget: Breaking up the initialization section into initialization/options sections and adding information on the default option values and how they can be changed. Fixes #126.
Wording tweaks per @scottgonzalez to make it clear that changing the defaults applies to future instances. (cherry picked from commit ce0f6c2ade5aa6766aae8b33586263391270becf)
1 parent 8fdd954 commit 821946a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

entries/jQuery.widget.xml

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,24 @@
2929
$( "#elem" ).progressbar();
3030
</code></pre>
3131

32-
<p>This will initialize each element in the jQuery object, in this case the element with an id of <code>"elem"</code>. Because we called the <code>progressbar()</code> method with no parameters, the widget is initialized with its default options. We can pass a set of options during initialization in order to override the default options.</p>
32+
<p>This will initialize each element in the jQuery object, in this case the element with an id of <code>"elem"</code>.</p>
33+
34+
<h3>Options</h3>
35+
36+
<p>Because <code>progressbar()</code> was called with no parameters, the widget was initialized with its default options. We can pass a set of options during initialization to override the defaults:</p>
3337

3438
<pre><code>
3539
$( "#elem" ).progressbar({ value: 20 });
3640
</code></pre>
3741

3842
<p>We can pass as many or as few options as we want during initialization. Any options that we don't pass will just use their default values.</p>
3943

44+
<p>The default values are stored on the widget's prototype, therefore we have the ability to override the values that jQuery UI sets. For example, after setting the following, all future progressbar instances will default to a value of 80:</p>
45+
46+
<pre><code>
47+
$.ui.progressbar.prototype.options.value = 80;
48+
</code></pre>
49+
4050
<p>The options are part of the widget's state, so we can set options after initialization as well. We'll see this later with the option method.</p>
4151

4252
<h3>Methods</h3>

0 commit comments

Comments
 (0)