Skip to content

Commit e7dd8df

Browse files
committed
Autocomplete: Documenting _renderItem() extension point.
1 parent 98479a1 commit e7dd8df

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

entries/autocomplete.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,36 @@
177177
<desc>Returns a <code>jQuery</code> object containing the menu element. Although the menu items are constantly created and destroyed, the menu element itself is created during initialization and is constantly reused.</desc>
178178
</method>
179179
</methods>
180+
<extension-points>
181+
<method name="_renderItem" return="jQuery">
182+
<desc>
183+
<p>Method that controls the creation of each option in the widget's menu. The method must create a new <code>&lt;li&gt;</code> element, append it to the menu, and return it.</p>
184+
<p><em>Note: At this time the<code>&lt;ul&gt;</code> element created must contain an <code>&lt;a&gt;</code> element for compatibility with the <a href="/menu/">menu</a> widget. See the example below.</em></p>
185+
</desc>
186+
<argument name="ul" type="jQuery">
187+
<desc>The <code>&lt;ul&gt;</code> element that the newly created <code>&lt;li&gt;</code> element must be appended to.</desc>
188+
</argument>
189+
<argument name="item" type="Object">
190+
<property name="label" type="String">
191+
<desc>The string to display for the item.</desc>
192+
</property>
193+
<property name="value" type="String">
194+
<desc>The value to insert into the input when the item is selected.</desc>
195+
</property>
196+
</argument>
197+
<example>
198+
<desc>Add the item's value as a data attribute on the <code>&lt;li&gt;</code>.</desc>
199+
<code><![CDATA[
200+
_renderItem: function( ul, item ) {
201+
return $( "<li>" )
202+
.attr( "data-value", item.value )
203+
.append( $( "<a>" ).text( item.label ) )
204+
.appendTo( ul );
205+
}
206+
]]></code>
207+
</example>
208+
</method>
209+
</extension-points>
180210
<example>
181211
<desc>A simple jQuery UI Autocomplete</desc>
182212
<code><![CDATA[

0 commit comments

Comments
 (0)