Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Default options class #21

Open
foglcz opened this Issue · 1 comment

2 participants

@foglcz

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.

@Klap-in

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

$.Autocompleter.defaults = {
    ...
    dataType: 'html',
    ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.