Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm not sure if this is new since https://drupal.org/node/1278042 but I'm having trouble when AJAX is enabled on my exposed forms. I've changed the .submit() callbacks to use jQuery's one instead which resolves my issue.
Comments
Comment #1
queenvictoria CreditAttribution: queenvictoria commentedPatch attached
Comment #2
drunken monkeyWith the patch applied, auto-submit doesn't work for me anymore. Does it work for you? And, have you also checked whether it works without Views AJAX enabled?
In my opinion, your code looks better than the old one so if it worked I'd definitely use it (unless someone else objects) – but it doesn't seem to, for whatever reason. (I couldn't find any obvious one, at least, and the code doesn't throw any errors either.)
Also, which browser do you use? Have you checked in others? I'm using Firefox 23.0. Maybe it's a compatibility issue? In that case, using jQuery is of course usually the safer option …
Comment #3
queenvictoria CreditAttribution: queenvictoria commentedYeah I noticed that. After a lot of clicking and submitting I've settled on clicking the submit button. Not sure what you think about this but it is what I can get to reliably do the following.
Comment #4
drunken monkeyAh, much better, thanks! Now nearly everything seems to work fine – except for your item 1, when AJAX is enabled. For me, this doesn't insert the autocomplete value before it submits the form via AJAX – e.g., if you type "fo", select the suggestion "foo" and press [Enter], the form will be submitted with "fo".
I tried to find out where this went wrong, but couldn't find it, sorry. Do you have some idea, maybe?
Also, what's the rationale between the new
return true
in the click handler?Comment #5
das-peter CreditAttribution: das-peter commentedDamn, that was a nasty one.
It looks like the ajax handling of the form is triggered before / during the autocomplete when hitting enter and thus misses the updated form value.
To stop enter from firing the ajax handling on its own I extended
Drupal.jsAC.prototype.onkeydown()
.Now
$(':submit', input.form).trigger('click');
really is the function that triggers the ajax handling after the new form value is set.I've created two patches. One that overwrites
Drupal.jsAC.prototype.onkeydown()
as it was done before withDrupal.jsAC.prototype.onkeyup()
and one that extends rather overwrites.Up to you what you like more - I personally prefer to copy / paste as few code as possible thus I'd try the extend patch ;)
Comment #6
drunken monkeyWorks fine for me, thanks for the great work!
Were you able to reproduce the error before applying any patches? For me, everything was working fine anyways so I'm not sure if this really fixes anything. However, it does clean up the code a little, I guess. (Just to clarify, the one with the "-optimized" suffix is the one you'd prefer?)
The best thing would of course be if the original issue creator could try out your patch(es), but it seems he's not following the issue anymore.
Comment #7
das-peter CreditAttribution: das-peter commentedHmm, can't exactly remember but my comment "Damn, that was a nasty one." suggests that it was an issue for me too and a nasty one :D
Yes
Comment #8
drunken monkeyOK, since it seems to work fine and apparently fixes a problem for some, I just committed the patch. We'll just have to see if complaints about the change pop up, I guess. ;)
Anyways, thanks a lot for your work, both of you!