jQuery Autocomplete using extraParams to pass additional GET variables

后端 未结 13 742
独厮守ぢ
独厮守ぢ 2021-01-31 17:23

I am referring specifically to the jQuery Autocomplete v1.1 plugin by Jörn Zaefferer [source: http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/] as there seems to

13条回答
  •  心在旅途
    2021-01-31 18:03

    While less than ideal, I've hacked/modified the plugin to get it to work for me.

    Simply, I've altered the AJAX jQuery function within the plugin.

    Around line 363 you'll see:

            $.ajax({
                // try to leverage ajaxQueue plugin to abort previous requests
                mode: "abort",
                // limit abortion to this input
                port: "autocomplete" + input.name,
                dataType: options.dataType,
                url: options.url,
                data: $.extend({
                    q: lastWord(term),
                    search_type: $(input).attr('name'), // my mod to pickup multiple fields
                    limit: options.max
                }, extraParams),
                success: function(data) {
                    var parsed = options.parse && options.parse(data) || parse(data);
                    cache.add(term, parsed);
                    success(term, parsed);
                }
            });
    

    I'm still looking for an elegant solution to this so feel free to keep suggestions coming.

提交回复
热议问题