Skip to content

jquery.widget: Breaking up the initialization section into initializatio... #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion entries/jQuery.widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,24 @@
$( "#elem" ).progressbar();
</code></pre>

<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>
<p>This will initialize each element in the jQuery object, in this case the element with an id of <code>"elem"</code>.</p>

<h3>Options</h3>

<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>

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

<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>

<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>

<pre><code>
$.ui.progressbar.prototype.options.value = 80;
</code></pre>

<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>

<h3>Methods</h3>
Expand Down