The autocomplete widget creates two objects, an ACDB and a jsAC. The ACDB reference is handed to jsAC and contains a reference to the URI to contact to get the autocomplete information. However, the jsAC is created and it's reference is thrown away when this line is run in autocompleteAutoAttach():

new jsAC(input, acdb[uri]);

I would like to suggest that this reference be attached to a variable that can be later modified, i.e.:

autocomplete_fields['edit-foo'].db.uri = 'http://example.com/new/auto/uri'

With this solution, a helper method might be nice, e.g.:

autocomplete_fields['edit-foo'].db.setUri('http://example.com/new/auto/uri')

Another alternative would be to store a reference to the original autocomplete input and use the value stored in the field rather than an internal variable. This would allow customizations like this:

document.getElementById('edit-foo-autocomplete').value = 'http://example.com/new/auto/uri'

I have a page that contains a select list that updates an autocomplete field based upon the most recent selection. As is, I've hacked the autocomplete.js so that it stores the autocomplete_fields as described. I've attached the patch that I've been using, which is just the very simple implementation of the first strategy.

CommentFileSizeAuthor
#3 autocomplete.js_.patch665 byteszostay
autocomplete.js_4.patch594 byteszostay
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

magico’s picture

Version: 4.7.3 » x.y.z

New features must be against CVS/HEAD

webchick’s picture

Version: x.y.z » 6.x-dev
Status: Needs review » Needs work

patching file misc/autocomplete.js
Hunk #1 succeeded at 17 with fuzz 2 (offset 12 lines).
Hunk #2 FAILED at 34.
1 out of 2 hunks FAILED -- saving rejects to file misc/autocomplete.js.rej

zostay’s picture

Status: Needs work » Needs review
FileSize
665 bytes

Here's a patch against 5.x. Previous failed because jsAC is now Drupal.jsAC.

catch’s picture

Version: 6.x-dev » 7.x-dev
Status: Needs review » Needs work

doesn't apply either. Needs to be rolled against HEAD.

Jaza’s picture

Version: 7.x-dev » 8.x-dev

bump.

nod_’s picture

Issue tags: +js-novice

tag

nod_’s picture

Issue summary: View changes
Status: Needs work » Closed (works as designed)
Issue tags: -js-novice +JavaScript, +Novice

I'm expecting jQuery UI autocomplete to have fixed that. If that's not the case please feel free to reopen.