Skip to content
This repository has been archived by the owner on Mar 16, 2018. It is now read-only.

Default options class #21

Open
foglcz opened this issue Aug 30, 2011 · 1 comment
Open

Default options class #21

foglcz opened this issue Aug 30, 2011 · 1 comment

Comments

@foglcz
Copy link

foglcz commented Aug 30, 2011

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
Copy link

Klap-in commented Nov 4, 2011

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants