Search and Top Navigation
#7260 closed enhancement (worksforme)
Opened April 15, 2011 04:06PM UTC
Closed April 16, 2011 03:06AM UTC
Last modified April 16, 2011 01:46PM UTC
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: |
Description
Hi,
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 this.input.autocomplete( { //options }); // Overidding rendering functions for this autcomplete instance (not all instances!) // In order to force HTML rendering (label can contains HTML) var autocomplete = this.input.data('autocomplete'); autocomplete._renderItem = function (ul, item) { return $("<li></li>") .data("item.autocomplete", item) .append($("<a></a>").html(item.label)) .appendTo(ul); };
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) { $.extend($.ui.autocomplete, { 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++
Attachments (0)
Change History (3)
Changed April 16, 2011 03:06AM UTC by comment:1
resolution: | → worksforme |
---|---|
status: | new → closed |
Changed April 16, 2011 11:54AM UTC by comment:2
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...
Changed April 16, 2011 01:46PM UTC by comment:3
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.
You can implement any logic you want with the source option.