Dynamic PreFill

conklirb's Avatar


23 Jun, 2010 08:53 PM

How would I dynamically build the preFill Object for existing elements? Basically, I need a URL that returns a list of people to preFill. I tried using a string like your website says for preFill, but I'm getting an error with that. If I put a static object in preFill, that works, but doesn't solve my problem. Any advice would be greatly appreciated!

  1. 1 Posted by conklirb on 23 Jun, 2010 10:23 PM

    conklirb's Avatar

    I came up with this to dynamically build an object from the html input value field. It works, not sure it's the best solution:

    $("[class*='autoS']").each(function() {

    var myJSONObj = eval('{items: [' + $(this).attr('value') + ']};');
    $(this).autoSuggest($(this).attr('AJAXURL'), {
      preFill: myJSONObj,
      selectedItemProp: "name",
      searchObjProps: "name",
      minChars: 2,
      asHtmlID: $(this).attr('class')


  2. 2 Posted by shogo2040 on 10 Aug, 2012 01:03 AM

    shogo2040's Avatar

    this will work on each element only once. If you called autoSuggest on an element that was previously initialized with autoSuggest, preFill will not work since it seems to only be supported on its first bind.

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