jQueryAutocompletePlugin icon indicating copy to clipboard operation
jQueryAutocompletePlugin copied to clipboard

Default options class

Open foglcz opened this issue 14 years ago • 1 comments

Hi, when using the plugin with default ajax handlers, the request might not go through (actually, not call the plugin's success function.) The cause was when I called something like this elsewhere in the scripts:

jQuery.ajaxSetup({
    success: myGenericHandler,
    dataType: "json"
});

Then, none of the requests would call the succes handler of autocomplete, therefore, not displaying the results.

Fix is on line 23, modify the default options class:


options = $.extend({}, $.Autocompleter.defaults, {
    url: isUrl ? urlOrData : null,
    data: isUrl ? null : urlOrData,
    delay: isUrl ? $.Autocompleter.defaults.delay : 10,
    max: options && !options.scroll ? 10 : 150,
    dataType : isUrl ? 'html' : null
}, options);

-> simply set the datatype.

The "datatype" parameter is used within the rest of the class, but there's no default value for it. Adding this line will fix the problem with issue above.

foglcz avatar Aug 30 '11 14:08 foglcz

It is only used for ajax requests, thus adding this to the $.Autocompleter.defaults is fine, isn't it?

$.Autocompleter.defaults = {
    ...
    dataType: 'html',
    ...
}

Klap-in avatar Nov 04 '11 13:11 Klap-in