If you have a readonly textfield with an autocomplete path, the autocomplete request fires when the user places the cursor in the field and presses any key, even though the textfield is readonly.
The use case for this is to have an autocomplete textfield that you want to enable through some other means (checkbox or other field filled in beforehand). In that case, you don't want the autocomplete to fire until the field is actually writeable.
I have attached an SVN patch with the hack that we will include on our platform, but since it uses jQuery() directly in the autocomplete's prototype context, I really don't think it is the best solution - but it's the best that I could come up with at that point in the code - I could perhaps have done something within the populatePopup() method itself, but I feel that it belongs with the check for input.value.length > 0
I would love it, if someone better at javascript/prototype/autocomplete could come up with a better solution.
Comment | File | Size | Author |
---|---|---|---|
#13 | 1631164-autocomplete_ro-6.x-13.patch | 500 bytes | Aron Novak |
#8 | 1631164_autocomplete_ro-8-only-condition.patch | 436 bytes | Aron Novak |
#8 | 1631164_autocomplete_ro-8.patch | 501 bytes | Aron Novak |
#4 | 1631164_autocomplete_ro-4.patch | 437 bytes | Aron Novak |
#2 | 1631164_autocomplete_ro-2.patch | 453 bytes | Aron Novak |
Comments
Comment #1
nod_That would be the best way to fix it, need to be fixed in D8 first.
Comment #2
Aron NovakBtw. it seems some browsers already implement this behaviour that they do not fire events when the field is read-only (in Opera, it seems it's like that, for example)
Comment #3
nod_There is no tricks with the readonly value, you don't need to go through jQuery to get it.
Comment #4
Aron NovakIndeed.
Comment #5
nod_Thanks :)
Comment #6
Dries CreditAttribution: Dries commentedCommitted to 8.x. Thanks!
Moving to 7.x.
Comment #7
marcingy CreditAttribution: marcingy commentedComment #8
Aron Novakre-rolled to the 7.x trivially
Comment #9
webchickWait. I'm confused. Which patch is for 7.x?
Comment #10
Aron NovakBoth. One of them only fixes the logical flaw only, the other one fixes some core beauty issue as well.
Comment #11
David_Rothstein CreditAttribution: David_Rothstein commentedCommitted to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/41f11d4
Comment #12
David_Rothstein CreditAttribution: David_Rothstein commentedActually, I guess this is an issue in D6 too.
Comment #13
Aron Novak