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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nod_’s picture

Version: 7.14 » 8.x-dev
Component: ajax system » javascript
Priority: Minor » Normal

That would be the best way to fix it, need to be fixed in D8 first.

Aron Novak’s picture

Status: Active » Needs review
FileSize
453 bytes

Btw. 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)

nod_’s picture

There is no tricks with the readonly value, you don't need to go through jQuery to get it.

Aron Novak’s picture

Indeed.

nod_’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

Thanks :)

Dries’s picture

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

Committed to 8.x. Thanks!

Moving to 7.x.

marcingy’s picture

Status: Reviewed & tested by the community » Needs work
Aron Novak’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
501 bytes
436 bytes

re-rolled to the 7.x trivially

webchick’s picture

Wait. I'm confused. Which patch is for 7.x?

Aron Novak’s picture

Both. One of them only fixes the logical flaw only, the other one fixes some core beauty issue as well.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed
David_Rothstein’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Patch (to be ported)
Issue tags: +Needs backport to D6

Actually, I guess this is an issue in D6 too.

Aron Novak’s picture

Status: Patch (to be ported) » Needs review
FileSize
500 bytes

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.