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.
Comment | File | Size | Author |
---|---|---|---|
#3 | autocomplete.js_.patch | 665 bytes | zostay |
autocomplete.js_4.patch | 594 bytes | zostay | |
Comments
Comment #1
magico CreditAttribution: magico commentedNew features must be against CVS/HEAD
Comment #2
webchickpatching 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
Comment #3
zostay CreditAttribution: zostay commentedHere's a patch against 5.x. Previous failed because jsAC is now Drupal.jsAC.
Comment #4
catchdoesn't apply either. Needs to be rolled against HEAD.
Comment #5
Jaza CreditAttribution: Jaza commentedbump.
Comment #6
nod_tag
Comment #7
nod_I'm expecting jQuery UI autocomplete to have fixed that. If that's not the case please feel free to reopen.