Skip to content

Commit d9b092f

Browse files
committed
jQuery.widget: Adding an example for _setOptions().
1 parent 5cff6e4 commit d9b092f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

entries/jQuery.widget.xml

+20
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,26 @@ _init: function() {
256256
Called whenever the <a href="#method-option"><code>option()</code></a> method is called, regardless of the form in which the <code>option()</code> method was called.
257257
<p>Overriding this is useful if you can defer processor-intensive changes for multiple option changes.</p>
258258
</desc>
259+
<example>
260+
<desc>Call a <code>resize()</code> method if the <code>height</code> or <code>width</code> options change.</desc>
261+
<code><![CDATA[
262+
_setOptions: function( options ) {
263+
var that = this,
264+
resize = false;
265+
266+
$.each( options, function( key, value ) {
267+
that._setOption( key, value );
268+
if ( key == "height" || key == "width" ) {
269+
resize = true;
270+
}
271+
});
272+
273+
if ( resize ) {
274+
this.resize();
275+
}
276+
}
277+
]]></code>
278+
</example>
259279
<argument name="options" type="Object">
260280
<desc>A map of option-value pairs to set.</desc>
261281
</argument>

0 commit comments

Comments
 (0)