bugs

Jake Chapa's Avatar

Jake Chapa

02 May, 2011 09:26 AM

1) The first item in the list of selected items doesn't get removed from the comma-delimited "values"
2) Auto-suggest will let you choose the same thing twice, only on the first item (ie "jake", then "jake" again)

These are due to the way you are removing the value. You are doing .replace("," + value + ",", ","). However, the first item doesn't have a leading comma.

I've fixed this by using a removeFromInput() function instead of your .replace() method:
function removeFromInput(val)

            {
                var inputs = values_input.val().split(',');

                for( var i = 0; i < inputs.length; i++ )
                    if( inputs[i] == val )
                    {
                        inputs.splice(i, 1);
                        i--;
                    }

                values_input.val(inputs.join(','));   // trailing comma for compatibility
            }

I've attached my modified file

  1. 1 Posted by David on 07 May, 2011 11:16 PM

    David's Avatar

    Thanks for putting up a fix, I just noticed the same problem. One thing you missed though, is that the first entry can still apear twice if it's typed in manually (ie. is not in the autocomplete list). To also fix this, just change the second condition in this line (case 9 / 188):

    if(i_input != "" && values_input.val().search(","+i_input+",") < 0 && i_input.length >= opts.minChars){

    to

    values_input.val().search(i_input+",") < 0

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • jquery.autoSuggest.js 13.6 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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