Skip to content

Commit 3668d38

Browse files
committed
[fix]: Custom example for widget classes option, show regular and deep setter
1 parent e918e9a commit 3668d38

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

entries/jQuery.widget.xml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,36 @@
192192
<xi:include href="../includes/widget-option-disabled.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
193193
<xi:include href="../includes/widget-option-hide.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
194194
<xi:include href="../includes/widget-option-show.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
195-
<option name="classes" default="{}" example-value='{ "custom-header": "icon-warning" }'>
195+
<option name="classes" default="{}">
196196
<desc>
197197
<p>Additional (thematic) classes to add to the widget, in addition to the structural classes. The structural classes are used as keys of this option and the thematic classes are the values. See the <a href="#method-_addClass"><code>_addClass()</code> method</a> for using this in custom widgets. Check out the documentation of individual widgets to see which classes they support.</p>
198198
<p>The primary motivation of this option is to map structural classes to theme classes. In other words, any class prefixed with namespace and widget, like <code>"ui-progressbar-"</code>, is considered a structural class. These are always added to the widget. In contrast to that, any class not specific to the widget is considered a theme class. These could be part of jQuery UI's CSS framework, but can also come from other CSS frameworks or be defined in custom stylesheets.</p>
199199
<p class="warning">Setting the <code>classes</code> option after creation will override all default properties. To only change specific values, use deep setters, e.g. <code>.option( "classes.ui-progressbar-value", null )</code>.</p>
200200
</desc>
201201
<type name="Object" />
202+
<example>
203+
<desc>Initialize a progressbar widget with the <code>classes</code> option specified, changing the theming for the <code>ui-progressbar</code> class:</desc>
204+
<code>
205+
$( ".selector" ).progressbar({
206+
classes: {
207+
"ui-progressbar": "highlight"
208+
}
209+
});
210+
</code>
211+
</example>
212+
<example>
213+
<desc>Get or set the <code>classes</code> option, after initialization:</desc>
214+
<code>
215+
// Getter
216+
var classes = $( ".selector" ).widget( "option", "classes" );
217+
218+
// Setter, override all classes
219+
$( ".selector" ).widget( "option", "classes", { "custom-header": "icon-warning" } );
220+
221+
// Setter, override just one class
222+
$( ".selector" ).widget( "option", "classes.custom-header", "icon-warning" );
223+
</code>
224+
</example>
202225
</option>
203226

204227
</options>

0 commit comments

Comments
 (0)