Skip to main content

Search and Top Navigation

#8928 closed feature (duplicate)

Opened December 20, 2012 01:48PM UTC

Closed December 20, 2012 02:33PM UTC

Last modified January 07, 2013 12:26PM UTC

Possibility to add class to autocomplete ul elements

Reported by: dickz Owned by:
Priority: minor Milestone: 1.10.0
Component: ui.autocomplete Version: 1.9.2
Keywords: Cc:
Blocked by: Blocking:
Description

It would be very useful to be able to specify a class that would be added to the <ul> elements that the autocomplete widget creates.

This could work in a way similar to what is possible with the dialog widget which allows you to specify a dialogClass in the options.

That way you could for example have different autocomplete widgets with different styling on the same page.

The workaround solution that I have used so far is to override the _renderMenu function, but it does not feel like a simple or good way to do it.

Attachments (0)
Change History (3)

Changed December 20, 2012 02:33PM UTC by scottgonzalez comment:1

resolution: → duplicate
status: newclosed

Duplicate of #7053.Overriding _renderMenu() is the correct thing to do today.

I'm closing as a duplicate of #7053, because it's either all or nothing. The dialogClass option needs to go away.

Changed December 20, 2012 02:35PM UTC by scottgonzalez comment:2

I should clarify a bit. Overriding _renderMenu() is only correct if you're building an extension that adds an option to add a class. The proper solution for end users is:

$( elem ).autocomplete({
    source: ...
}).autocomplete( "widget" ).addClass( "whatever" );

Changed January 07, 2013 12:26PM UTC by dickz comment:3

Thank you for your quick reply. I had not understood/discovered the widget method earlier, but your last example is exactly what I really wanted, rather than overriding _renderMenu. Perhaps it would be a good idea to add it as a "code example" for the widget method?