Add items to the field after the initial loading?

James Simpson's Avatar

James Simpson

19 May, 2011 06:11 PM

I started using the jSuggest modification ( since it solved all of the issues I had been having. However, there is one thing that I absolutely need, but can't figure out how to implement. I'm using this as a country selection tool, and I have some preset bundles of countries that I want a user to be able to click on and add into the list.

However, I see no way to call addItem outside of the plugin. Any ideas on how this could be achieved?

  1. 1 Posted by mekn on 21 May, 2011 08:18 PM

    mekn's Avatar

    as far as i remember you cant add tokens programatically,
    Maybe you can reload that input and change with a specific object that will hold the data, and pass it to the preFill option.

  2. 2 Posted by James Simpson on 22 May, 2011 02:58 PM

    James Simpson's Avatar

    I'm not familiar with this word "can't."

    By reload the input do you mean reinitialize the auto suggest after resetting what is in it?

  3. 3 Posted by brian on 03 Jun, 2011 07:14 PM

    brian's Avatar

    Hi james, were you able to solve this? i'm having the same issue.

  4. 4 Posted by James Simpson on 03 Jun, 2011 07:30 PM

    James Simpson's Avatar

    Well, I couldn't find an elegant solution (was sort of in a time crunch), but I've put together a jsbin with my hacked together solution. The updated javascript is on the left panel, and at the bottom of the HTML is the function that should be run and passed the JSON object with the data for the item(s) you want to add.

  5. 5 Posted by brian on 03 Jun, 2011 08:46 PM

    brian's Avatar

    hi james, thank you for your prompt response. checking out the preview, the autosuggest doesn't seem to be coming up in your example?

  6. 6 Posted by James Simpson on 03 Jun, 2011 09:24 PM

    James Simpson's Avatar

    Sorry, I didn't actually have a chance to test what I put into jsbin. If you go to and go to the 2nd screen where you select countries, you can see the working example of what I've made (bundles of countries).

    The uncompressed files are and the function that is included in the HTML section of the jsbin (add_item).

  7. 7 Posted by brian on 07 Jun, 2011 02:50 PM

    brian's Avatar

    Hi James,
    Thanks for your modified code, i got it working for me. doing some debugging, do you get this error (in ff) below when you click on the input box or try to close a tag?

    uncaught exception: Syntax error, unrecognized expression: hover

  8. 8 Posted by James Simpson on 07 Jun, 2011 11:03 PM

    James Simpson's Avatar

    No, I'm not getting any errors. If you have somewhere I can e-mail you, I can send you the link to my implementation (I don't want to post it publicly since it is still in stealth and the middle of development).

Reply to this discussion

Internal reply

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

Attaching KB article:


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


? 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