bug: first record can be added twice
Hello,
Thanks for this great plugin. There is a small bug:
If you refresh the page http://code.drewwilson.com/entry/autosuggest-jquery-plugin (hold down shift to clear cache) the demo field will allow you to add the first selected record twice. If I remove the selected fields I can't reproduce the problem before the page is refreshed/cache cleared again.
Hope I have posted in the right place.
-
screen-capture-32.png 39.6 KB
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by philip on 01 Sep, 2010 02:18 PM
Here is a way to fix it:
Change line 275
FROM:
if(str.search(query) != -1 && values_input.val().search(","+data[num][opts.selectedValuesProp]+",") == -1){
TO:
if(str.search(query) != -1 && (','+values_input.val()+',').search(","+data[num][opts.selectedValuesProp]+",") == -1){
Hope this helps ;)
Best
Philip
2 Posted by philip on 01 Sep, 2010 05:01 PM
This post complements the previous:
Add a line after line 326
FROM:
function add_selected_item(data, num){
TO:
function add_selected_item(data, num){
if (values_input.val().indexOf(",")==-1) addinstr=','; else addinstr='';
Best,
Philip
3 Posted by philip on 01 Sep, 2010 05:03 PM
Line 326
TO:
function add_selected_item(data, num){
if (values_input.val().indexOf(",")==-1) addinstr=','; else addinstr='';
values_input.val(addinstr+values_input.val()+data[opts.selectedValuesProp]+",");
I forgot the last changing line.
Sorry :)
4 Posted by Lakhats on 02 Sep, 2010 06:25 PM
Thanks philip... Its working now...
5 Posted by Asbjørn Morell on 24 Oct, 2010 10:11 PM
Hey,
You fixed seems to have created a new bug. I can't create a duplicate record any more, however something get's messed up if I add two users, remove them and try to add them again. The last laser won't show up any more...
6 Posted by Blake on 09 Feb, 2011 07:13 AM
add this to line #46
selectionRemoved: function(elem) {
7 Posted by Joe Mocker on 02 Sep, 2011 06:18 PM
Ahh. Great fix. That was bugging the heck out of me.