Skip to content

Commit 7f44f57

Browse files
fnageljzaefferer
authored andcommitted
Selectmenu: Add documentation for _renderButtonItem() extension point
Closes gh-226
1 parent f3eb725 commit 7f44f57

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

entries/selectmenu.xml

+40
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,46 @@ _renderMenu: function( ul, items ) {
203203
_resizeMenu: function() {
204204
this.menu.outerWidth( 500 );
205205
}
206+
]]></code>
207+
</example>
208+
</method>
209+
<method name="_renderButtonItem" return="jQuery">
210+
<desc>
211+
<p>Method that controls the creation of the generated button content. The method must create and return a new element.</p>
212+
</desc>
213+
<argument name="item" type="Object">
214+
<property name="disabled" type="Boolean">
215+
<desc>Whether the item is disabled.</desc>
216+
</property>
217+
<property name="element" type="jQuery">
218+
<desc>A reference to the item's original <code>&lt;option&gt;</code> element.</desc>
219+
</property>
220+
<property name="index" type="Number">
221+
<desc>The numeric index of the item.</desc>
222+
</property>
223+
<property name="label" type="String">
224+
<desc>The string to display for the item.</desc>
225+
</property>
226+
<property name="optgroup" type="String">
227+
<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>
228+
</property>
229+
<property name="value" type="String">
230+
<desc>The <code>value</code> attribute of the item's original <code>&lt;option&gt;</code>.</desc>
231+
</property>
232+
</argument>
233+
<example>
234+
<desc>Style the button background color based on the value of the selected option.</desc>
235+
<code><![CDATA[
236+
_renderButtonItem: function( item ) {
237+
var buttonItem = $( "<span>", {
238+
"class": "ui-selectmenu-text"
239+
})
240+
this._setText( buttonItem, item.label );
241+
242+
buttonItem.css( "background-color", item.value )
243+
244+
return buttonItem;
245+
}
206246
]]></code>
207247
</example>
208248
</method>

0 commit comments

Comments
 (0)