agarzola / jQueryAutocompletePlugin

Jörn Zaefferer’s (now deprecated) jQuery plugin, with tweaks.
282 stars 151 forks source link

little problem with setOptions and extraParams, fix included #1

Closed smarques closed 13 years ago

smarques commented 13 years ago

I noticed a problem when using setOptions to add an extra param, after the field has been initialized and used. the code looks like this bind("setOptions", function() { $.extend( options, arguments[1]); // if we've updated the data, repopulate if ( "data" in arguments[1] ) cache.populate(); }) this means the extend call is NOT recursive, but I think it should be, or alle xtraParams would be erased by any subsequent call attemting to just add a new extra param, not removing the old ones...

my fix was to change the code like this, note the first param to extend that turns on recursive merge... this option is available only in jquery > 1.4: bind("setOptions", function() { $.extend(true, options, arguments[1]); // if we've updated the data, repopulate if ( "data" in arguments[1] ) cache.populate(); })

agarzola commented 13 years ago

Thanks for your input, smarques. I will look into and test this fix. Will let you know if/when I push the change.

Thanks again!

agarzola commented 13 years ago

Hi, smarques. I looked into this and found no conflicts. I’ve added the fix to all three flavors fo the plugin, tested them against 1.4.4 and 1.3.2 and both seem to work just fine (recursive merging was introduced on version 1.1.4 of jQuery, as opposed to 1.4; I too misunderstood it at first!).

I’ve pushed the fix and bumped the plugin up to version 1.2. I also gave you credit for finding and reporting this bug. Thanks a lot!