Skip to content

Commit b2e5a95

Browse files
committed
FormResetMixin: Initial docs
1 parent 4f52955 commit b2e5a95

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

entries/form-reset-mixin.xml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0"?>
2+
<entries>
3+
<entry type="widget" name="jQuery.ui.formResetMixin">
4+
<title>Form Reset Mixin</title>
5+
<desc>A mixin to call <code>refresh()</code> on a form widget when the parent form gets reset.</desc>
6+
<methods suppress-auto-examples="true">
7+
<method name="_bindFormResetHandler">
8+
<desc>
9+
Call <code>this._bindFormResetHandler()</code> inside <code>_create()</code> to initialize the mixin.
10+
</desc>
11+
<example>
12+
<desc>Set the background color of the widget's element based on an option.</desc>
13+
<code><![CDATA[
14+
_create: function() {
15+
this._bindFormResetHandler();
16+
}
17+
]]></code>
18+
</example>
19+
</method>
20+
<method name="_unbindFormResetHandler">
21+
<desc>
22+
Call <code>this._unbindFormResetHandler()</code> inside <code>_destroy()</code> to destroy the mixin.
23+
</desc>
24+
<example>
25+
<desc></desc>
26+
<code><![CDATA[
27+
_destroy: function() {
28+
this._unbindFormResetHandler();
29+
}
30+
]]></code>
31+
</example>
32+
</method>
33+
</methods>
34+
<example>
35+
<height>50</height>
36+
<desc>Plain number spinner</desc>
37+
<code><![CDATA[
38+
$.widget( "custom.colorize", [ $.ui.formResetMixin, {
39+
_create: function() {
40+
this.element.css( "background-color", "red" );
41+
this._bindFormResetHandler();
42+
},
43+
_refresh: function() {
44+
this.element.css( "background-color", "black" );
45+
},
46+
_destroy: function() {
47+
this._unbindFormResetHandler();
48+
}
49+
});
50+
$( "#colorize" ).colorize();
51+
]]></code>
52+
<css><![CDATA[
53+
#colorize {
54+
width: 50px;
55+
height: 50px;
56+
border: 1px solid black;
57+
}
58+
]]></css>
59+
<html><![CDATA[
60+
<form>
61+
<div id="colorize"></div>
62+
<button type="reset">Reset form</html>
63+
</form>
64+
]]></html>
65+
</example>
66+
<category slug="utilities"/>
67+
<category slug="widgets"/>
68+
</entry>
69+
</entries>

0 commit comments

Comments
 (0)