Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#7260 closed enhancement (worksforme)

Autocomplete filter each instance

Reported by: TiTi Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.autocomplete Version: 1.8.11
Keywords: Cc:
Blocked by: Blocking:



In the autocomplete plugin, i'm overriding several functions for some instances, ex:

this.input = $('<input type="text" />').appendTo(document.body);

// Using jQuery ui autocomplete module

// Overidding rendering functions for this autcomplete instance (not all instances!)
// In order to force HTML rendering (label can contains HTML)
var autocomplete ='autocomplete');
autocomplete._renderItem = function (ul, item)
	return $("<li></li>")
		.data("item.autocomplete", item)

It would be great if such override - for a specific instance - is possible for the filter method. For now I can only override it globally :

if ($.ui)
		filter: function(results, term)
                        //ex: dealing with accents, show only dates, ... etc
			return stuff;


The comment shows various usage: I'd like one autocomplete to show only dates, one other only text, .... => I've already done some filtering on the datasource of course. I'm just asking for more granularity, because it's hard for me to do this for example:

Have an autocomplete filled with dates such as (10/02/2001, 10.02.2001, 10-02-2001) and make all thoses 3 values match for the search '10.02.2001' or the search '10/02/2001', or even the search '10.02/2001'. Got it ? Thx++

Change History (3)

comment:1 Changed 10 years ago by Scott González

Resolution: worksforme
Status: newclosed

You can implement any logic you want with the source option.

comment:2 Changed 10 years ago by TiTi

uh? what was that? Did you read my ticket?! So if you can do everything with the source option, how can I manage to do what I'm saying at the END of the ticket?

Maybe a filter function for each specific autocomplete instance is not the good solution, but then at least provide me an explanation which is not that generic...

Anyhow, this is the kind of answer that really piss me off, because you obviously didn't fully read my ticket and you didn't provide me a concrete solution. If this is your way to thank developers for jQuery bug reporting and ideas, wow...

comment:3 Changed 10 years ago by Scott González

I'm sorry you feel that way. I did read the full ticket and the solution is already documented. The overview section of the autocomplete documentation explains how to use the source option. There are also several demos showing how to customize autocomplete. Specifically, the accent folding demo shows how to do exactly what you want.

Note: See TracTickets for help on using tickets.