Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In jQuery UI 1.9+, extending a widget is done in the same manner as creating a new widget. The widget factory (<code>$.widget()</code>) supports a few scenarios:</p> <p>Creating a new widget using the base widget (<code>$.Widget</code>) as the starting point:</p> <p><code>$.widget( "ns.widget", { ... } )</code></p> <p>Creating a new widget that inherits from an existing widget:</p> <p><code>$.widget( "ns.widget", $.ns.existingWidget, { ... } )</code></p> <p>Extending a widget:</p> <p><code>$.widget( "ns.widget", $.ns.widget, { ... } )</code></p> <p>You'll notice that the extending syntax and the inheritance syntax are the same. The widget factory is smart enough to notice that the widget you're creating and the widget you're inheriting from are the same and handle it appropriately.</p> <p>When inheriting or extending a widget, you only need to define what you want to change or add. There are also a few new methods that exist on the base widget to make it easier to work with inheritance and methods that change context. Read the <a href="http://api.jqueryui.com/jQuery.widget/#jQuery-Widget2" rel="noreferrer">jQuery.Widget documentation</a> for a full list of methods and their descriptions. You'll definitely want to read about <a href="http://api.jqueryui.com/jQuery.widget/#method-_super" rel="noreferrer">_super()</a> if you're extending a widget.</p> <p>Here's an example that would change the default <code>delay</code> option to <code>500</code> and add a new option <code>prefix</code> which is added to all suggestions:</p> <pre><code>$.widget( "ui.autocomplete", $.ui.autocomplete, { options: { delay: 500, prefix: "" }, _renderItem: function( ul, item ) { var label = item.label; if ( this.options.prefix ) { label = this.options.prefix + " " + label; } return $( "&lt;li&gt;" ) .append( $( "&lt;a&gt;" ).text( label ) ) .appendTo( ul ); }, }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload