Skip to content

Commit 9a14fc1

Browse files
committed
Selectmenu: Add documentation for _renderButtonItem extension point
1 parent 968ebbf commit 9a14fc1

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

entries/selectmenu.xml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,53 @@
119119
<desc>Returns a <code>jQuery</code> object containing the button element.</desc>
120120
</method>
121121
</methods>
122+
<extension-points>
123+
<method name="_renderButtonItem" return="jQuery">
124+
<desc>
125+
<p>Method that controls the creation of the generated button content. The method must create and return a new element.</p>
126+
</desc>
127+
<argument name="item" type="Object">
128+
<property name="disabled" type="Boolean">
129+
<desc>Whether the item is disabled.</desc>
130+
</property>
131+
<property name="element" type="jQuery">
132+
<desc>A reference to the item's original <code>&lt;option&gt;</code> element.</desc>
133+
</property>
134+
<property name="index" type="Number">
135+
<desc>The numeric index of the item.</desc>
136+
</property>
137+
<property name="label" type="String">
138+
<desc>The string to display for the item.</desc>
139+
</property>
140+
<property name="optgroup" type="String">
141+
<desc>If the item is within an <code>&lt;optgroup&gt;</code>, this is set to that <code>&lt;optgroup&gt;</code>'s label.</desc>
142+
</property>
143+
<property name="value" type="String">
144+
<desc>The <code>value</code> attribute of the item's original <code>&lt;option&gt;</code>.</desc>
145+
</property>
146+
</argument>
147+
<example>
148+
<desc>Add a <a href="/theming/icons/">jQuery UI icon</a> to each generated button who's select has a <code>data-icon</code> attribute.</desc>
149+
<code><![CDATA[
150+
_renderButtonItem = function( item ) {
151+
var buttonItem = $( "<span>", {
152+
"class": "ui-selectmenu-text"
153+
})
154+
this._setText( buttonItem, item.label );
155+
156+
buttonItem
157+
.css( "padding-left", "2.5em" )
158+
.append( "<span>" )
159+
.find( "span" )
160+
.addClass( "ui-icon " + item.element.attr( "data-icon") )
161+
.css( "left", "0.5em" );
162+
163+
return buttonItem;
164+
}
165+
]]></code>
166+
</example>
167+
</method>
168+
</extension-points>
122169
<example>
123170
<desc>A simple jQuery UI Selectmenu</desc>
124171
<code><![CDATA[

0 commit comments

Comments
 (0)