What are the “response” and “request” arguments in jQuery UI Autocomplete's “source” callback?

后端 未结 3 2014
一向
一向 2021-02-03 12:19

I\'m looking at the autocomplete tutorial, and I have a few questions: http://jqueryui.com/demos/autocomplete/#option-disabled

$( \"#tags\" )
            // don\         


        
3条回答
  •  时光取名叫无心
    2021-02-03 12:32

    It's clearly documented in the jQuery UI autocomplete page.

    http://jqueryui.com/demos/autocomplete/

    The third variation, the callback, provides the most flexibility, and can be used to connect any data source to Autocomplete. The callback gets two arguments:

    A request object, with a single property called "term", which refers to the value currently in the text input. For example, when the user entered "new yo" in a city field, the Autocomplete term will equal "new yo".

    A response callback, which expects a single argument to contain the data to suggest to the user. This data should be filtered based on the provided term, and can be in any of the formats described above for simple local data (String-Array or Object-Array with label/value/both properties). It's important when providing a custom source callback to handle errors during the request. You must always call the response callback even if you encounter an error. This ensures that the widget always has the correct state.

提交回复
热议问题