annotate sites/all/modules/custom/solrsearch_autocomplete/jquery-autocomplete/todo @ 0:015d06b10d37 default tip

initial
author dwinter
date Wed, 31 Jul 2013 13:49:13 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
015d06b10d37 initial
dwinter
parents:
diff changeset
1 TODO
015d06b10d37 initial
dwinter
parents:
diff changeset
2
015d06b10d37 initial
dwinter
parents:
diff changeset
3 - test formatItem implementation that returns (clickable) anchors
015d06b10d37 initial
dwinter
parents:
diff changeset
4 - bug: handle del key; eg. type a letter, remove it using del, type same letter again: nothing happens
015d06b10d37 initial
dwinter
parents:
diff changeset
5 - handle up/down keys in textarea (prevent default while select is open?)
015d06b10d37 initial
dwinter
parents:
diff changeset
6 - docs: max:0 works, too, "removing" it(??)
015d06b10d37 initial
dwinter
parents:
diff changeset
7 - fix ac_loading/options.loadingClass
015d06b10d37 initial
dwinter
parents:
diff changeset
8 - support/enable request urls like foo/bar/10 instead of foo/q=10
015d06b10d37 initial
dwinter
parents:
diff changeset
9 - urlencode request term before passing to $.ajax/data; evaluate why $.ajax doesn't handle that itself, if at all; try with umlauts, russian/danish/chinese characeters (see validate)
015d06b10d37 initial
dwinter
parents:
diff changeset
10 - test what happens when an element gets focused programmatically (maybe even before then autcomplete is applied)
015d06b10d37 initial
dwinter
parents:
diff changeset
11 - check if blur on selecting can be removed
015d06b10d37 initial
dwinter
parents:
diff changeset
12 - fix keyhandling to ignore metakeys, eg. shift; especially important for chinese characters that need more then one key
015d06b10d37 initial
dwinter
parents:
diff changeset
13 - enhance mustMatch: provide event/callback when a value gets deleted
015d06b10d37 initial
dwinter
parents:
diff changeset
14 - handle tab key different then enter, eg. don't blur field or prevent default, just let it move on; in any case, no need to blur the field when selecting a value via tab, unlike return
015d06b10d37 initial
dwinter
parents:
diff changeset
15 - prevent redundant requests on
015d06b10d37 initial
dwinter
parents:
diff changeset
16 - superstring returned no result, no need to query again for substring, eg. pete returned nothing, peter won't either
015d06b10d37 initial
dwinter
parents:
diff changeset
17 - previous query mustn't be requested again, eg. pete returns 10 lines, peter nothing, backspace to pete should get the 10 lines from cache (may need TimeToLive setting for cache to invalidate it)
015d06b10d37 initial
dwinter
parents:
diff changeset
18 - incorporate improvements and suggestions by Hector: http://beta.winserver.com/public/test/MultiSuggestTest.wct
015d06b10d37 initial
dwinter
parents:
diff changeset
19 - json support: An optional JSON format, that assumes a certain JSON format as default and just looks for a dataType "json" to be activated; [records], where each record is { id:String, label:String, moreOptionalValues... }
015d06b10d37 initial
dwinter
parents:
diff changeset
20 - accept callback as first argument to let users implement their own dynamic data (no caching) - consider async API
015d06b10d37 initial
dwinter
parents:
diff changeset
21 - allow users to keep their incomplete value when pressing tab, just mimic the default-browser-autocomplete: tab doesn't select any proposed value -> tab closes the select and works normal otherwise
015d06b10d37 initial
dwinter
parents:
diff changeset
22 - small bug in your autocomplete, When setting autoFill:true I would expect formatResult to be called on autofill, it seems not to be the case.
015d06b10d37 initial
dwinter
parents:
diff changeset
23 - add a callback to allow decoding the response
015d06b10d37 initial
dwinter
parents:
diff changeset
24 - allow modification of not-last value in multiple-fields
015d06b10d37 initial
dwinter
parents:
diff changeset
25 @option Number size Limit the number of items to show at once. Default:
015d06b10d37 initial
dwinter
parents:
diff changeset
26 @option Function parse - TEST AND DOCUMENT ME
015d06b10d37 initial
dwinter
parents:
diff changeset
27 - add option to display selectbox on focus
015d06b10d37 initial
dwinter
parents:
diff changeset
28
015d06b10d37 initial
dwinter
parents:
diff changeset
29 $input.bind("show", function() {
015d06b10d37 initial
dwinter
parents:
diff changeset
30 if ( !select.visible() ) {
015d06b10d37 initial
dwinter
parents:
diff changeset
31 onChange(0, true);
015d06b10d37 initial
dwinter
parents:
diff changeset
32 }
015d06b10d37 initial
dwinter
parents:
diff changeset
33 });
015d06b10d37 initial
dwinter
parents:
diff changeset
34
015d06b10d37 initial
dwinter
parents:
diff changeset
35 - reference: http://capxous.com/
015d06b10d37 initial
dwinter
parents:
diff changeset
36 - add "try ..." hints to demo
015d06b10d37 initial
dwinter
parents:
diff changeset
37 - check out demos
015d06b10d37 initial
dwinter
parents:
diff changeset
38 - reference: http://createwebapp.com/demo/
015d06b10d37 initial
dwinter
parents:
diff changeset
39
015d06b10d37 initial
dwinter
parents:
diff changeset
40 - add option to hide selectbox when no match is found - see comment by Ian on plugin page (14. Juli 2007 04:31)
015d06b10d37 initial
dwinter
parents:
diff changeset
41 - add example for reinitializing an autocomplete using unbind()
015d06b10d37 initial
dwinter
parents:
diff changeset
42
015d06b10d37 initial
dwinter
parents:
diff changeset
43 - Add option to pass through additional arguments to $.ajax, like type to use POST instead of GET
015d06b10d37 initial
dwinter
parents:
diff changeset
44
015d06b10d37 initial
dwinter
parents:
diff changeset
45 - I found out that the problem with UTF-8 not being correctly sent can be solved on the server side by applying (PHP) rawurldecode() function, which decodes the Unicode characters sent by GET method and therefore URL-encoded.
015d06b10d37 initial
dwinter
parents:
diff changeset
46 -> add that hint to docs and examples
015d06b10d37 initial
dwinter
parents:
diff changeset
47
015d06b10d37 initial
dwinter
parents:
diff changeset
48 But I am trying this with these three values: “foo bar”, “foo foo”, and “foo far”, and if I enter “b” (or “ba”) nothing matches, if I enter “f” all three do match, and if I enter “fa” the last one matches.
015d06b10d37 initial
dwinter
parents:
diff changeset
49 The problem seems to be that the cache is implemented with a first-character hashtable, so only after matching the first character, the latter ones are searched for.
015d06b10d37 initial
dwinter
parents:
diff changeset
50
015d06b10d37 initial
dwinter
parents:
diff changeset
51 xml example:
015d06b10d37 initial
dwinter
parents:
diff changeset
52 <script type="text/javascript">
015d06b10d37 initial
dwinter
parents:
diff changeset
53 function parseXML(data) {
015d06b10d37 initial
dwinter
parents:
diff changeset
54 var results = [];
015d06b10d37 initial
dwinter
parents:
diff changeset
55 var branches = $(data).find('item');
015d06b10d37 initial
dwinter
parents:
diff changeset
56 $(branches).each(function() {
015d06b10d37 initial
dwinter
parents:
diff changeset
57 var text = $.trim($(this).find('text').text());
015d06b10d37 initial
dwinter
parents:
diff changeset
58 var value = $.trim($(this).find('value').text());
015d06b10d37 initial
dwinter
parents:
diff changeset
59 //console.log(text);
015d06b10d37 initial
dwinter
parents:
diff changeset
60 //console.log(value);
015d06b10d37 initial
dwinter
parents:
diff changeset
61 results[results.length] = {'data': this, 'result': value, 'value': text};
015d06b10d37 initial
dwinter
parents:
diff changeset
62 });
015d06b10d37 initial
dwinter
parents:
diff changeset
63 $(results).each(function() {
015d06b10d37 initial
dwinter
parents:
diff changeset
64 //console.log('value', this.value);
015d06b10d37 initial
dwinter
parents:
diff changeset
65 //console.log('text', this.text);
015d06b10d37 initial
dwinter
parents:
diff changeset
66 });
015d06b10d37 initial
dwinter
parents:
diff changeset
67 //console.log(results);
015d06b10d37 initial
dwinter
parents:
diff changeset
68 return results;
015d06b10d37 initial
dwinter
parents:
diff changeset
69 };
015d06b10d37 initial
dwinter
parents:
diff changeset
70 $(YourOojHere).autocomplete(SERVER_AJAX_URL, {parse: parseXML});
015d06b10d37 initial
dwinter
parents:
diff changeset
71 </script>
015d06b10d37 initial
dwinter
parents:
diff changeset
72 <?xml version="1.0"?>
015d06b10d37 initial
dwinter
parents:
diff changeset
73 <ajaxresponse>
015d06b10d37 initial
dwinter
parents:
diff changeset
74 <item>
015d06b10d37 initial
dwinter
parents:
diff changeset
75 <text>
015d06b10d37 initial
dwinter
parents:
diff changeset
76 <![CDATA[<b>FreeNode:</b> irc.freenode.net:6667]]>
015d06b10d37 initial
dwinter
parents:
diff changeset
77 </text>
015d06b10d37 initial
dwinter
parents:
diff changeset
78 <value><![CDATA[irc.freenode.net:6667]]></value>
015d06b10d37 initial
dwinter
parents:
diff changeset
79 </item><item>
015d06b10d37 initial
dwinter
parents:
diff changeset
80 <text>
015d06b10d37 initial
dwinter
parents:
diff changeset
81 <![CDATA[<b>irc.oftc.net</b>:6667]]>
015d06b10d37 initial
dwinter
parents:
diff changeset
82 </text>
015d06b10d37 initial
dwinter
parents:
diff changeset
83 <value><![CDATA[irc.oftc.net:6667]]></value>
015d06b10d37 initial
dwinter
parents:
diff changeset
84 </item><item>
015d06b10d37 initial
dwinter
parents:
diff changeset
85 <text>
015d06b10d37 initial
dwinter
parents:
diff changeset
86 <![CDATA[<b>irc.undernet.org</b>:6667]]>
015d06b10d37 initial
dwinter
parents:
diff changeset
87 </text>
015d06b10d37 initial
dwinter
parents:
diff changeset
88 <value><![CDATA[irc.undernet.org:6667]]></value>
015d06b10d37 initial
dwinter
parents:
diff changeset
89 </item>
015d06b10d37 initial
dwinter
parents:
diff changeset
90 </ajaxresponse>
015d06b10d37 initial
dwinter
parents:
diff changeset
91
015d06b10d37 initial
dwinter
parents:
diff changeset
92
015d06b10d37 initial
dwinter
parents:
diff changeset
93
015d06b10d37 initial
dwinter
parents:
diff changeset
94 Hi all,
015d06b10d37 initial
dwinter
parents:
diff changeset
95
015d06b10d37 initial
dwinter
parents:
diff changeset
96 I use Autocomplete 1.0 Alpha mostly for form inputs bound to foreign
015d06b10d37 initial
dwinter
parents:
diff changeset
97 key columns. For instance I have a user_position table with two
015d06b10d37 initial
dwinter
parents:
diff changeset
98 columns: user_id and position_id. On new appointment form I have two
015d06b10d37 initial
dwinter
parents:
diff changeset
99 autocomplete text inputs with the following code:
015d06b10d37 initial
dwinter
parents:
diff changeset
100
015d06b10d37 initial
dwinter
parents:
diff changeset
101 <input type="text" id="user_id" class="ac_input" tabindex="1" />
015d06b10d37 initial
dwinter
parents:
diff changeset
102 <input type="text" id="position_id" class="ac_input" tabindex="2" />
015d06b10d37 initial
dwinter
parents:
diff changeset
103
015d06b10d37 initial
dwinter
parents:
diff changeset
104 As you can see the inputs do not have a name attribute, and when the
015d06b10d37 initial
dwinter
parents:
diff changeset
105 form is submitted their values are not sent, which is all right since
015d06b10d37 initial
dwinter
parents:
diff changeset
106 they will contain strings like:
015d06b10d37 initial
dwinter
parents:
diff changeset
107
015d06b10d37 initial
dwinter
parents:
diff changeset
108 'John Doe'
015d06b10d37 initial
dwinter
parents:
diff changeset
109 'Sales Manager'
015d06b10d37 initial
dwinter
parents:
diff changeset
110
015d06b10d37 initial
dwinter
parents:
diff changeset
111 whereas our backend expects something like:
015d06b10d37 initial
dwinter
parents:
diff changeset
112
015d06b10d37 initial
dwinter
parents:
diff changeset
113 23
015d06b10d37 initial
dwinter
parents:
diff changeset
114 14
015d06b10d37 initial
dwinter
parents:
diff changeset
115
015d06b10d37 initial
dwinter
parents:
diff changeset
116 which are the user_id for John Doe and position_id for Sales Manager.
015d06b10d37 initial
dwinter
parents:
diff changeset
117 To send these values I have two hidden inputs in the form like this:
015d06b10d37 initial
dwinter
parents:
diff changeset
118
015d06b10d37 initial
dwinter
parents:
diff changeset
119 <input type="hidden" name="user_id" value="">
015d06b10d37 initial
dwinter
parents:
diff changeset
120 <input type="hidden" name="position_id" value="">
015d06b10d37 initial
dwinter
parents:
diff changeset
121
015d06b10d37 initial
dwinter
parents:
diff changeset
122 Also I have the following code in the $().ready function:
015d06b10d37 initial
dwinter
parents:
diff changeset
123
015d06b10d37 initial
dwinter
parents:
diff changeset
124 $("#user_id").result(function(event, data, formatted) {
015d06b10d37 initial
dwinter
parents:
diff changeset
125 $("input[@name=user_id]").val(data[1]);
015d06b10d37 initial
dwinter
parents:
diff changeset
126 });
015d06b10d37 initial
dwinter
parents:
diff changeset
127 $("#position_id").result(function(event, data, formatted) {
015d06b10d37 initial
dwinter
parents:
diff changeset
128 $("input[@name=position_id]").val(data[1]);
015d06b10d37 initial
dwinter
parents:
diff changeset
129 });
015d06b10d37 initial
dwinter
parents:
diff changeset
130
015d06b10d37 initial
dwinter
parents:
diff changeset
131 As could be seen these functions stuff user_id and position_id values
015d06b10d37 initial
dwinter
parents:
diff changeset
132 (in our example 23 and 14) into the hidden inputs, and when the form
015d06b10d37 initial
dwinter
parents:
diff changeset
133 is submitted these values are sent:
015d06b10d37 initial
dwinter
parents:
diff changeset
134
015d06b10d37 initial
dwinter
parents:
diff changeset
135 user_id = 23
015d06b10d37 initial
dwinter
parents:
diff changeset
136 position_id = 14
015d06b10d37 initial
dwinter
parents:
diff changeset
137
015d06b10d37 initial
dwinter
parents:
diff changeset
138 The backend script then takes care of adding a record to our
015d06b10d37 initial
dwinter
parents:
diff changeset
139 user_position table containing those values.
015d06b10d37 initial
dwinter
parents:
diff changeset
140
015d06b10d37 initial
dwinter
parents:
diff changeset
141 I wonder how could the plugin code be modified to simplify the setup
015d06b10d37 initial
dwinter
parents:
diff changeset
142 by taking care of adding hidden inputs and updating the value of
015d06b10d37 initial
dwinter
parents:
diff changeset
143 hidden inputs as default behavior. I have successfully attempted a
015d06b10d37 initial
dwinter
parents:
diff changeset
144 simpler solution - writing a wrapper to perform these additional tasks
015d06b10d37 initial
dwinter
parents:
diff changeset
145 and invoke autocomplete as well. I hope my intention is clear enough,
015d06b10d37 initial
dwinter
parents:
diff changeset
146 if not, this is exactly the expected outcome:
015d06b10d37 initial
dwinter
parents:
diff changeset
147
015d06b10d37 initial
dwinter
parents:
diff changeset
148 Before:
015d06b10d37 initial
dwinter
parents:
diff changeset
149
015d06b10d37 initial
dwinter
parents:
diff changeset
150 <script type="text/javascript"
015d06b10d37 initial
dwinter
parents:
diff changeset
151 src="jquery.autocomplete-modified.js"></script>
015d06b10d37 initial
dwinter
parents:
diff changeset
152 <input type="text" name="user_id" class="ac_input" tabindex="1" />
015d06b10d37 initial
dwinter
parents:
diff changeset
153
015d06b10d37 initial
dwinter
parents:
diff changeset
154 After:
015d06b10d37 initial
dwinter
parents:
diff changeset
155
015d06b10d37 initial
dwinter
parents:
diff changeset
156 <input type="text" id="user_id" class="ac_input" tabindex="1" />
015d06b10d37 initial
dwinter
parents:
diff changeset
157 <input type="hidden" name="user_id" value="23">
015d06b10d37 initial
dwinter
parents:
diff changeset
158
015d06b10d37 initial
dwinter
parents:
diff changeset
159
015d06b10d37 initial
dwinter
parents:
diff changeset
160 Last word, I know this looks like a tall order, and I do not hope
015d06b10d37 initial
dwinter
parents:
diff changeset
161 someone will make a complete working mod for me, but rather would very
015d06b10d37 initial
dwinter
parents:
diff changeset
162 much appreciate helpful advise and directions.
015d06b10d37 initial
dwinter
parents:
diff changeset
163
015d06b10d37 initial
dwinter
parents:
diff changeset
164 Many thanks in advance
015d06b10d37 initial
dwinter
parents:
diff changeset
165 Majid
015d06b10d37 initial
dwinter
parents:
diff changeset
166