Hi,
when i submit a form first time this module works fine, but if a required field is left blank, the page is submitted (not using client side validation) and as expected the missing fields message show, so a user fills it, now if you click submit again the module doesn't work, users can click 2 or 3 times submitting the form again and again.

it throws this error:
Uncaught TypeError: Cannot read property 'hide_submit_method' of undefined

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jonloh’s picture

Version: 7.x-2.0 » 7.x-2.x-dev
Status: Active » Needs review
FileSize
1.78 KB

We will need to add the JS and CSS in #after_build as well. The patch attached should fix this issue.

stupiddingo’s picture

Status: Needs review » Reviewed & tested by the community

We were seeing the same behavior on form validation error and resubmit. This patch resolves the error.

greggles’s picture

I tried to replicate this error:

1. on a custom form that has required fields I filled in 2 of the fields and hit submit, the button hides
2. I get an error that the field is required
3. I fill in the field and hit submit again, the button disappears as expected

Are there any more steps to replicate the error? What kind of form were you using?

stupiddingo’s picture

FileSize
9.57 KB
61.16 KB
5.08 KB

:crickets: ...nearly a year passes... sorry about that!

Steps to replicate

1. Install Drupal with standard profile
2. Download and enable hide submit 7.x-2.x-dev
3. Open Internet Explorer (yes, really... I know, I know. In some builds of Firefox you can do this as well)
3. Submit an article without a title (validation will fire)
4. Add a title and some serious content to slow things (The Wikipedia article for World War II was sufficiently verbose https://en.wikipedia.org/wiki/World_War_II)
4. Resubmit double-clicking like you are using Windows 3.1 (for best results just keep clicking)
Duplicity

In Internet Explorer console you can see this error:
Unable to get property 'hide_submit_method' of undefined or null reference

Even Chrome is opinionated about this but I can't make multiple submissions successfully:
Chrome not happy but still submits for us

The patch https://www.drupal.org/files/issues/hide_submit-uncaught-typeerror-when-... resolves this behavior in all my tests on IE, Chrome and Firefox.

rymcveigh’s picture

Issue summary: View changes
FileSize
101.6 KB
24.95 KB

I was able to replicate the issue on FF ver. 41.0.2 Mac on both simplytest.me and a clean VM install, I was unable to create multiple pages with Chrome Version 46.0.2490.80 (64-bit) Mac, and was able to replicate the issue on IE 10 Windows 7 on a clean VM install. Using the latest ver. of the module and Drupal 7.

FF Content:
FF Content
FF Console:
Only local images are allowed.
IE Content:
Only local images are allowed.
IE Console:
Only local images are allowed.

stupiddingo’s picture

In my testing I was able to create duplicates on:
- Internet Explorer 11.0.9600.17728 (and older versions in compatibility mode)
- Firefox 41.0.2 & Firefox 42.0 (Windows)

Here you can see the dups created in the same second on IE and Firefox:
Only local images are allowed.

While this testing was done on Acquia Dev Desktop, I have had the same behavior happening from IE visitors on my production sites hosted on both WIMP and LAMP.

Ryan, sorry but I'm not following your comment. You're unable to create duplicates, yet the drupal message on node create is repeated? What am I missing? I suspect on /admin/content you'd see double posts in those scenarios.

stupiddingo’s picture

Apparently I can't read well this morning.

/me goes and gets some more coffee.

My bad Ryan. I missed the "able to replicate".

rymcveigh’s picture

FileSize
98.18 KB

Sorry, I'm working through it as I go. Here is what I'm seeing on FF after the initial fail. Looks like it could be due to a jquery issue:

Only local images are allowed.

rymcveigh’s picture

No worries. I was actually able to create 4 instances of content on IE 10 win 7 with the setting on the module set to disable. So, yeah, its an issue. I'm going to test with jQuery update just to see if using an updated version of jQuery helps.

rymcveigh’s picture

I ran a series of tests using different configs with and without jquery_update, here are the results:

With jQuery update disabled and Hide submit button set to "hide submit buttons" I was able to create 4 nodes at once.

With jquery update disabled and Hide submit button set to "disable submit buttons" I was NOT able to create more than one node at a time.

With jquery update enabled and set to jquery ver. 1.7, and Hide submit button set to "disable submit buttons" I was able to create 2 nodes at once.

With jquery update enabled and set to jquery ver. 1.8, and Hide submit button set to "disable submit buttons" I was NOT able to create more than 1 node at once.

With jquery update enabled and set to jquery ver. 1.8, and Hide submit button set to "hide submit buttons" I was NOT able to create more than 1 node at once BUT the btn did not hide.

With jquery update enabled and set to jquery ver. 1.7, and Hide submit button set to "hide submit buttons" I was NOT able to create more than 1 node at once BUT the btn did not hide.

With jquery update enabled and set to the default supplied by drupal, and Hide submit button set to "hide submit buttons" I was able to create 2 nodes at once AND the btn did not hide.

With jquery update enabled and set to the default supplied by drupal, and Hide submit button set to "disable submit buttons" I was NOT able to create more than one node at once.

In IE 10 Win. 7 I was able to create multiple nodes with any of the above settings. IE once again wins the "Most likely to fail" award. :)

rymcveigh’s picture

FileSize
9.66 KB

I've tested this patch a couple times now and it seems to have resolved the issue. Stupiddingo, when you have a moment, will you please review with this patch and let me know if it works for you? Thanks.

Instructions for applying patch: https://www.drupal.org/project/hide_submit/git-instructions

rymcveigh’s picture

Status: Reviewed & tested by the community » Needs review

Added adjusted patch. This new patch now needs to be reviewed.

rymcveigh’s picture

stupiddingo’s picture

Status: Needs review » Reviewed & tested by the community

Tested successfully using the articles method above, highly customized node forms and webforms on the following:
- Android: Chrome, Firefox
- Linux: Chromium, Firefox
- iOS: Safari
- Windows: IE11, Chrome, Firefox

Bonus! It now correctly hides the "Delete" button as well which over enthusiastic data editors of mine were successfully clicking in double-clicking the save button on edits and consequently performing the unfortunate "uplete" submission.

This patch may also resolve these issues:
https://www.drupal.org/node/2393923
https://www.drupal.org/node/2388697

greggles’s picture

Status: Reviewed & tested by the community » Fixed

Cool, committed now. Thanks Ryan, jonloh and stupiddingo!

  • greggles committed 4dfbf4d on 7.x-2.x authored by rymcveigh
    Issue #2317141 by rymcveigh, jonloh: Uncaught TypeError when...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.