Ticket #8928 (closed feature: duplicate)

Opened 21 months ago

Last modified 20 months ago

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:
Blocking: Blocked by:

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.

Change History

comment:1 Changed 21 months ago by scott.gonzalez

  • Status changed from new to closed
  • Resolution set to duplicate

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.

comment:2 Changed 21 months ago by scott.gonzalez

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" );

comment:3 Changed 20 months ago by dickz

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?

Note: See TracTickets for help on using tickets.