Hi daniel,
here is a problem that many of my users reported:
search forms with only one autocomplete-field require 2 hits on enter to submit the form
and I really understand that this is necessary for forms with multiple inputs because
the first return takes the suggestion into the input and the second return submits the
form but this behavior is really annoying when you intent to submit your search on
first return. maybe this behavior appeared to you on api.drupal.org and as you are a
module developer I suppose you use that search box quite often :)
I know that must be some sort of standard-drupal JS but it would be very nice if one
had in autocomplete-finder setting an option to change if one or two returns are
necessary to submit the form and depending on this setting the standard-drupal JS
or maybe a custom JS is used...
Comments
Comment #1
danielb commentedTried to change this behaviour before but I didn't get anywhere. Patches welcome.
Using a completely custom JS may be worth considering, but I will have to think about it a little more.
Comment #2
dsms commented/misc/autocomplete.js automaticly attaches its functionality on every input with class="autocomplete".
the easiest way would be to fork autocomplete.js to lets say singleautocomplete.js and change the following lines:
25-29:
Drupal.autocompleteSubmit = function () {
return $('#autocomplete').each(function () {
this.owner.hidePopup();
}).size() == 0;
};
to:
Drupal.autocompleteSubmit = function () {
return $('#autocomplete').each(function () {
this.owner.hidePopup();
this.form.submit();
}).size() == 0;
};
this works very well.
now the complicated part: if configured in Finder, Autocomplete Finder should output other css-classes,
for example <input class="singleautocomplete" ...> instead of <input class="autocomplete" ...>
and the forked singleautocomplete.js now has to look for "singleautocomplete" instead of "autocomplete".
when done, just copy the singleautocomplete.js to your module-folder and push it to $scripts
via drupal_add_js() if configured in Finder :)
Comment #3
danielb commentedDoesn't work for mouse clicks.... I'm trying a few things now
Comment #4
danielb commentedI've added this in alpha 20, it's actually a config option in the finder element form settings.
Might need to rebuild theme stuff first
Comment #5
dsms commentedwow! that are great news! thank you
Comment #6
dsms commentedsorry, I don't find this setting. I created a new node finder, with setting "Redirect to the only result node,..." plus an Autocomplete
field but the autocomplete settings are the same as in alpha19 :( I thought it would be in "Finder form element settings"
Comment #7
danielb commentedSorry about that, seems none of the changes commited yesterday made it into the release? :/ There should be a good one up soon.
Comment #8
Gyt commentedIt's may be a very good feature, but now it's not work right.
With option "Submit upon selection" autocomplete field submit the form, when:
Comment #9
danielb commentedI believe I have solved this. I will add it to the next commit.
Comment #10
danielb commentedOK it is much better now.
Comment #11
Gyt commentedSorry, but alpha25=alpha26 :)
Comment #12
danielb commentedsorry about that, I was excited I fixed it and forgot to commit the code.
Comment #13
Gyt commentedOh, another error.
When I use finder block with option "Submit upon selection", all autocomplete forms on page submit their forms upon selection. For example, autocomplete taxonomy submit a node, when I add term.
Comment #14
danielb commentedI'm not sure I follow. The autocompletes that aren't meant to submit upon selection do so because there is another autocomplete on the page with this feature?
Comment #15
Gyt commentedYes. I disabled finder block on node form pages, but it isn't a good solution.
Comment #16
danielb commentedOK there was a bug with an object being called the same thing as the original .js, It's fixed. Thanks.
Comment #18
Anonymous (not verified) commentedissue pops up again on D7
Comment #19
danielb commented...