Example does not work

Charlie's Avatar


10 Mar, 2010 01:01 AM

What am I doing wrong? I wish there was a downloadable example...

Also, is there a way to modify the way the search is performed. I need to return the results of each item that contains all of the search terms entered which are separated by spaces.

  1. 1 Posted by Andrew on 10 Mar, 2010 03:40 PM

    Andrew's Avatar

    Try putting the js code in the body of the page, after the input box like this:

    <input id="my1Activity" size="100" type="text"> 
    <script type="text/javascript">
    var data = {items: [
    {value: "21", name: "Mick Jagger"},
    {value: "43", name: "Johnny Storm"},
    {value: "46", name: "Richard Hatch"},
    {value: "54", name: "Kelly Slater"},
    {value: "55", name: "Rudy Hamilton"},
    {value: "79", name: "Michael Jordan"}
    $("input#my1Activity").autoSuggest(data.items, {selectedItemProp: "name", searchObjProps: "name", startText: "", keyDelay: 50, minChars: 1});

    Also, you don't need all 3 js files in the head of the document, just the minified or packed one will do unless you're planning on altering the code.

  2. 2 Posted by Charlie on 10 Mar, 2010 04:42 PM

    Charlie's Avatar

    Thanks Andrew. That worked!

  3. 3 Posted by Cody on 18 Mar, 2010 09:50 PM

    Cody's Avatar

    Odd when I use that example it searches by the value still.

  4. 4 Posted by ZenOne on 31 Mar, 2010 07:53 PM

    ZenOne's Avatar

    @Charlie Can you post the working example?

  5. 5 Posted by Victor Engmark on 14 Apr, 2010 12:56 PM

    Victor Engmark's Avatar

    @ZenOne Here's a working XHTML 1.1 version

  6. 6 Posted by Moiz on 20 Apr, 2010 08:46 AM

    Moiz's Avatar

    could someone help me with an issue i am having with the preFill option.

    $("#BLG_tags").autoSuggest("http://localhost/adm/admin/mod_blog/generate_tags.php", {selectedItemProp: "name", searchObjProps: "name", asHtmlID:'01', startText:'Enter tags here ...', emptyText: 'No tags found that match your search', preFill:'1,2,' });

    Notice the preFill passed as a string. the 1 and 2 are the values in the json, however the name does not appear. instead there is an error on this line


    if you alert data[opts.selectedItemProp] it will return undefined.

    could someone solve this for me

  7. Support Staff 7 Posted by Drew Wilson on 21 Apr, 2010 05:20 PM

    Drew Wilson's Avatar


    That was a bug that is now fixed :) Thanks!
    THe new AutoSuggest version will be out soon. But you can add this line of code:

    v_data[opts.selectedItemProp] = vals[i];

    right after line 90, which is:
    v_data[opts.selectedValuesProp] = vals[i];


  8. 8 Posted by Moiz Sitabkhan on 21 Apr, 2010 06:53 PM

    Moiz Sitabkhan's Avatar

    Hi Drew!

    Thanks for the update !! I will add this to the code and see how it

    Btw the plugin is awesum!

    Moiz Sitabkhan.

    Sent from an iPhone 3GS

  9. 9 Posted by Moiz on 22 Apr, 2010 09:53 AM

    Moiz's Avatar

    Hi Drew,

    there seems to be another problem now.

    The preFill loads the data ... but it is the JSON value field.

    if i use this preFill:1,4,5

    instead on displaying technology, concept, idea it displays 1,4,5 as the tags.

    the JSON file has this format


  10. Support Staff 10 Posted by Drew Wilson on 22 Apr, 2010 04:43 PM

    Drew Wilson's Avatar

    This is not a problem with the plugin at all.
    You are passing a String as the 'preFill'. Therefore the only value you are giving to AutoSuggest for each item is a single number, ex. '1,' or '2' or '3'.
    When you 'preFill' using a string it is not possible to give a single item more than 1 value. If you want to do that pass in a JSON object and NOT a string.
    A JSON object will allow you to set more than 1 value per item ... just like you have listed above in your JSON example.



  11. 11 Posted by Moiz Sitabkhan on 22 Apr, 2010 05:52 PM

    Moiz Sitabkhan's Avatar

    Hi Drew

    Alright, let me try this out and let you know if it works

    I believe that format will be [{id:value}]


    Moiz Sitabkhan.

    Sent from an iPhone 3GS

Reply to this discussion

Internal reply

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

Attaching KB article:


Already uploaded files

  • test.html 997 Bytes

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