initial selected values

Todd's Avatar

Todd

29 Apr, 2010 02:47 PM

Hi,
I must be missing something in API...

I have AutoSuggest working fine, but have this use case-

Use AutoSuggest to tag "Documents" which is working fine. But, if user comes back to Document tag again, I need to show their previously saved tags.

I've tried setting the input value field to CSV.... tried setting-
$('input[class=as-values]').val() = "Mick Jagger,Michael Jordan";

But, I can get preexisting tags to show in the autocomplete input.

Thoughts and Suggestions appreciated,

Todd

  1. 1 Posted by Todd on 29 Apr, 2010 03:00 PM

    Todd's Avatar

    Pardon me...
    I've tried:
    $('input[class=as-values]').val("Mick Jagger,Michael Jordan"); not:
    $('input[class=as-values]').val() = "Mick Jagger,Michael Jordan";

    as originally posted. Still doesn't work though

  2. Support Staff 2 Posted by Drew Wilson on 29 Apr, 2010 03:37 PM

    Drew Wilson's Avatar

    Use the "preFill" option in the API.

    Thanks!
    Drew

  3. 3 Posted by Todd on 29 Apr, 2010 05:30 PM

    Todd's Avatar

    Thanks Drew, but all I can ever get the text box to show is "Enter Name Here", not Mick Jagger tag loaded in input as I'm trying to show here:

        var autosuggest_data = {items: [
              {value: "Mick Jagger", name: "Mick Jagger"},
              {value: "Johnny Storm", name: "Johnny Storm"},
              {value: "Richard Hatch", name: "Richard Hatch"},
              {value: "Kelly Slater", name: "Kelly Slater"},
              {value: "Rudy Hamilton", name: "Rudy Hamilton"},
              {value: "Michael Jordan", name: "Michael Jordan"}
          ]};
          $("input[name=tags]").autoSuggest(autosuggest_data.items, {
              selectedItemProp: "name",
              searchObjProps: "name",
              preFill: 'Mick Jagger'
          });
    
  4. 4 Posted by Todd on 29 Apr, 2010 05:36 PM

    Todd's Avatar

    Ok, got it. In case someone else needs an example-

          var autosuggest_data = {items: [
              {value: "Mick Jagger", name: "Mick Jagger"},
              {value: "Johnny Storm", name: "Johnny Storm"},
              {value: "Richard Hatch", name: "Richard Hatch"},
              {value: "Kelly Slater", name: "Kelly Slater"},
              {value: "Rudy Hamilton", name: "Rudy Hamilton"},
              {value: "Michael Jordan", name: "Michael Jordan"}
          ]};
    
          var selected_data = {items: [
             {value: "Mick Jagger", name: "Mick Jagger"}
          ]};
          $("input[name=tags]").autoSuggest(autosuggest_data.items, {
              selectedItemProp: "name",
              searchObjProps: "name",
              preFill: selected_data.items
          });
    

Comments are currently closed for this discussion. You can start a new one.

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