Programatically reset the autosuggest

Ispan Arnold's Avatar

Ispan Arnold

29 Nov, 2011 08:35 AM


I have a form and on one of the fields i use autosuggest. The form will be submitted as ajax with jquery forms plugin and afterwards hidden (it will be shown when u click on an ADD button).
The issue is that after the submit the field that usses autosuggest still contains the value from the previous submit.
How could i reset, empty this?


  1. 1 Posted by Joe on 08 Dec, 2011 04:14 AM

    Joe's Avatar

    I'm trying to do exactly the same thing!

    Hopefully someone can post a solution to this

  2. 2 Posted by Jon on 05 Jan, 2012 08:30 AM

    Jon's Avatar


    I've done it using a trigger (don't know if someone has already posted a solution). Copy this after the moveSelection function:

    var elementId = "#" + opts.asHtmlID;
    $(elementId).bind("reset", function(event) {
        $.each($(".as-selection-item"), function(index, value){,$(value));

    Then call the trigger function:


    (where XXXX is the value of 'asHtmlID')

  3. 3 Posted by Jason Chua on 11 Jan, 2012 08:04 AM

    Jason Chua's Avatar


    There is a bug in the above code. It will reset all autoSuggest input because it is using common selector ".as-selection-item". Below is the corrected code.

    `var elementId = "#" + opts.asHtmlID; $(elementId).bind("reset", function(event) {

    $.each($("#as-selections-"+opts.asHtmlID+" .as-selection-item"), function(index, value){,$(value));

    Happy coding!

  4. 4 Posted by Jon on 11 Jan, 2012 12:58 PM

    Jon's Avatar

    Yes, you're right.
    My solution could be usefull as a "Reset All" function,jeje.

    Thank you for the fix.

  5. 5 Posted by shogo2040 on 15 Aug, 2012 11:43 PM

    shogo2040's Avatar

    very nice solution using jQuery custom events.

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