|
119 | 119 | <desc>Returns a <code>jQuery</code> object containing the button element.</desc>
|
120 | 120 | </method>
|
121 | 121 | </methods>
|
| 122 | + <extension-points> |
| 123 | + <method name="_renderItem" return="jQuery"> |
| 124 | + <desc> |
| 125 | + <p>Method that controls the creation of each option in the widget's menu. The method must create a new <code><li></code> element, append it to the menu, and return it.</p> |
| 126 | + </desc> |
| 127 | + <argument name="ul" type="jQuery"> |
| 128 | + <desc>The <code><ul></code> element that the newly created <code><li></code> element must be appended to.</desc> |
| 129 | + </argument> |
| 130 | + <argument name="item" type="Object"> |
| 131 | + <property name="element" type="jQuery"> |
| 132 | + <desc>The original <code>option</code> element.</desc> |
| 133 | + </property> |
| 134 | + <property name="index" type="Integer"> |
| 135 | + <desc>The index of the <code>option</code> within the <code>select</code>.</desc> |
| 136 | + </property> |
| 137 | + <property name="value" type="String"> |
| 138 | + <desc>The value of the <code>option</code>.</desc> |
| 139 | + </property> |
| 140 | + <property name="label" type="String"> |
| 141 | + <desc>The label of the <code>option</code>.</desc> |
| 142 | + </property> |
| 143 | + <property name="optgroup" type="String"> |
| 144 | + <desc>The label for the parent <code>optgroup</code>, if any.</desc> |
| 145 | + </property> |
| 146 | + <property name="disabled" type="Boolean"> |
| 147 | + <desc>Whether the <code>option</code> is disabled.</desc> |
| 148 | + </property> |
| 149 | + </argument> |
| 150 | + <example> |
| 151 | + <desc>Style the menu item backgrounds based on their value.</desc> |
| 152 | + <code><![CDATA[ |
| 153 | +_renderItem: function( ul, item ) { |
| 154 | + var li = $( "<li>" ) |
| 155 | + .css( "background-color", item.value ); |
| 156 | +
|
| 157 | + if ( item.disabled ) { |
| 158 | + li.addClass( "ui-state-disabled" ); |
| 159 | + } |
| 160 | +
|
| 161 | + this._setText( li, item.label ); |
| 162 | +
|
| 163 | + return li.appendTo( ul ); |
| 164 | +} |
| 165 | +]]></code> |
| 166 | + </example> |
| 167 | + </method> |
| 168 | + <method name="_renderMenu"> |
| 169 | + <desc> |
| 170 | + Method that controls building the widget's menu. The method is passed an empty <code><ul></code> and an array of items based on the <code>option</code> elements in the original <code>select</code>. Creation of the individual <code><li></code> elements should be delegated to <code>_renderItemData()</code>, which in turn delegates to the <a href="#method-_renderItem"><code>_renderItem()</code></a> extension point. |
| 171 | + </desc> |
| 172 | + <argument name="ul" type="jQuery"> |
| 173 | + <desc>An empty <code><ul></code> element to use as the widget's menu.</desc> |
| 174 | + </argument> |
| 175 | + <argument name="items" type="Array"> |
| 176 | + <desc>An Array of items based on the <code>option</code> elements in the original <code>select</code>. See the <a href="#method-_renderItem"><code>_renderItem()</code></a> extension point for details on the format of the item objects.</desc> |
| 177 | + </argument> |
| 178 | + <example> |
| 179 | + <desc> |
| 180 | + <p>Add a CSS class name to the odd menu items.</p> |
| 181 | + <div class="warning"><strong>Note:</strong> For simplicity, this example does not support optgroups or disabled menu items.</div> |
| 182 | + </desc> |
| 183 | + <code><![CDATA[ |
| 184 | +_renderMenu: function( ul, items ) { |
| 185 | + var that = this; |
| 186 | + $.each( items, function( index, item ) { |
| 187 | + that._renderItemData( ul, item ); |
| 188 | + }); |
| 189 | + $( ul ).find( "li:odd" ).addClass( "odd" ); |
| 190 | +} |
| 191 | +]]></code> |
| 192 | + </example> |
| 193 | + </method> |
| 194 | + <method name="_resizeMenu"> |
| 195 | + <desc>Method responsible for sizing the menu before it is displayed. The menu element is available at <code>this.menu</code>.</desc> |
| 196 | + <example> |
| 197 | + <desc>Always display the menu as 500 pixels wide.</desc> |
| 198 | + <code><![CDATA[ |
| 199 | +_resizeMenu: function() { |
| 200 | + this.menu.outerWidth( 500 ); |
| 201 | +} |
| 202 | +]]></code> |
| 203 | + </example> |
| 204 | + </method> |
| 205 | + </extension-points> |
122 | 206 | <example>
|
123 | 207 | <desc>A simple jQuery UI Selectmenu</desc>
|
124 | 208 | <code><![CDATA[
|
|
0 commit comments