The current default timeouts of 500 ms (.5 seconds) are not suitable for all fields or use-cases. Site owners may want to allow for longer timeouts, especially for text fields, where a user may have a second or more between keystrokes.
Additionally, there are issues (such as #1069966: Blocks exposed filters have wrong url in form action) with views exposed filters where pressing the enter key will submit the form to an incorrect URL specified in the form's action tag (particularly on block views with exposed filters). Allowing the auto-submit.js script to capture these ENTER keystrokes and ignore them will prevent that error from occurring (at least when JavaScript is enabled).
This patch allow users to set different timeouts for text fields and all other types, as well as optionally ignore ENTER keypresses.
Due to how the javascript is included by Drupal, modules wishing to take advantage of will need to tweak how they attach the auto-submit.js file and add a setting variable that can be passed through to the javascript. This has already been done to the needed CTools Page Manager filter.
A simple change to the Views module will allow it to work properly with Views Exposed Filters. Use the #6 Patch against the Dev version of Views, or in .../views/plugins/views_plugin_exposed_form.inc after this:
$form['#attached']['js'][] = drupal_get_path('module', 'ctools') . '/js/auto-submit.js';
(around line 270) add this code to pull in the settings and pass them through to the auto-submit.js script:
// Send auto-submit settings to javascript if supported by current version of ctools.
if (function_exists('ctools_get_auto_submit_settings')) {
$form['#attached']['js'][] = array('data' => ctools_get_auto_submit_settings(), 'type' => 'setting');
}
Flush your caches and it should start working.
The patch adds a CTools settings page where the timeouts and ENTER ignoring can be configured:

| Comment | File | Size | Author |
|---|---|---|---|
| #24 | ctools_configure_autosubmit_timeouts-2781117-24.patch | 13.18 KB | hotwebmatter |
| #22 | ctools_configure_autosubmit_timeouts-2781117-22.patch | 11.37 KB | rivimey |
| ctools_timeout_settings_screenshot.png | 61.25 KB | diamondsea |
Comments
Comment #2
diamondseaPatch against 7.x-1.x-dev.
Comment #3
diamondseaComment #4
diamondseaAdded missing ctools.admin.inc file to patch
Comment #5
diamondseaRerolled patch against latest dev version.
Comment #6
diamondseaThis is the patch to be applied against Views to enable the new ctools timeout settings to be passed through. This patch will be submitted to the Views issue queue after this issue has been merged into cTools.
Comment #7
mmcintosh commentedReviewed and tested #5 (ctools patch) and #6 (views patch) both install with no errors and work as expected I can now change the auto-submit timeout. This was done on fresh install druapl: 7.50 ctools version: 7.x-1.10+0-dev and views: 7.x-3.14+5-dev. I also ran both patches through Drupal coder and no problems were found in all 6 hunks. Thanks for the patch it will help fix some issues that we have had for a long time.
Comment #8
diamondseaComment #9
brooke_heaton commentedReviewed and tested #5 (ctools patch) and #6 (views patch) against Drupal 7.50, Ctools 7.x-1.10+0-dev and Views 7.x-3.14+5-dev. Both worked for me. Great patch and upgrade to autosubmit.
Comment #10
brooke_heaton commentedComment #11
japerryWill need to be re-rolled to work with changes from #2275355: Auto submit to submit a non-existent form.
Comment #12
diamondseaRerolled against latest Dev version. NOTE: you will still also need the Views patch in #6 for it to work on exposed filters.
Comment #13
diamondseaComment #14
rivimeyWe are trying to improve the test coverage... please, please include some tests that exercise this code.
Comment #15
xenophyle commentedSeems like #12 needs ctools.admin.inc, or am I missing something...
Comment #16
rivimey@xenophyle I think you are quite correct... @diamondsea could you redo the patch please?
Comment #17
darrenwh commentedA few DCS items.
These comments go over the DCS 80 char limit in places lines 20, 21,29 and 32
Missing period at end of line.
Missing period at end of line.
Missing period and capital.
As above
As above
Line goes over DCS 80 char limit.
Look to break line so array on separate lines and does not go beyond DCS char limit
Comment #18
chris-adhome commentedApplied Patch #5 & #6 and everything is working as it should. Will report back any issues if I find them.
Thanks for your efforts diamondsea!
Comment #19
hotwebmatter commentedThe
hook_menu()in patch #12 neededctools.admin.incand the custom'administer ctools settings'permission before it would work for me.I found
ctools.admin.incin patch #5, and added the permission myself.This should work better out of the box. Be sure to grant the custom
'administer ctools settings'permission to yourself, or you will not be able to access the CTools Settings at/admin/config/system/ctools.Thanks @diamondsea!
NOTE: you will still also need the Views patch in #6 for it to work on exposed filters.
Comment #20
antonyanimator commentedReceived following when applying patch:
Comment #21
joelpittetLikely needs a reroll
Comment #22
rivimeyRerolled, also removed packaging info from the .info file.
Comment #23
rivimeyComment #24
hotwebmatter commentedThanks for the re-roll @rvimey -- I can confirm that it's working for me.
I added the
ctools.admin.incfile, which is easy to leave out by mistake since it's a new file rather than a patch to an existing file. (People who have already applied an earlier version of the patch will be able to use the patch in #22, but people who have never applied it before will need thectools.admin.incfile in order to configure the timeout values.)Comment #25
rpayanmComment #26
japerryDrupal 7 is no longer supported, closing.