Sometimes, it is very handfull to pass to autocomplete route additional parameters, not only the text that come from input textfield.
Example: Form with field "City" (select) and "Street" (autocomplete). I want to search streets only in chosen city.
Yes, I know I can make "#ajax" property for "City" field, then on form ajax rebuild pass the city id to "'#autocomplete_route_parameters' => array('city' => 13)," property of "Street" form field. (I didn't test that way yet).
But there is a way better, without additional ajax requests.
I want to add custom js library, that handle changes of "City" field, and on change it would do something like this:
jQuery.extend(true, Drupal.autocomplete.ajax, {data: {city: 13}});
But then autocomplete should make recursive merge of Drupal.autocomplete.ajax. Please see the patch and jQuery.extend doc: http://api.jquery.com/jquery.extend/
| Comment | File | Size | Author |
|---|---|---|---|
| improve_autocomplete.js_.patch | 550 bytes | andyceo |
Comments
Comment #1
andypostComment #2
andyceo commentedComment #3
markdorisonComment #4
droplet commentedI like the patch but worrying about the backward compatibility
Comment #5
andypost@droplet please point where it breaks BC? I suppose it implementation details that does not affect contrib
Comment #6
droplet commented@andypost,
We didn't expect deep copy before. Data are not filtered in CORE / Contrib.
Comment #19
smustgrave commentedWas it determined this would cause a BC issue?
Comment #21
smustgrave commentedSince there hasn't been a follow up going to close out for now.
If still a valid request please reopen.
Thanks!