This repository was archived by the owner on Jun 21, 2022. It is now read-only.
#144 confirm if unsaved form changes - #169
Open
tjfoerster wants to merge 3 commits into
Open
Conversation
dboehmer
suggested changes
May 30, 2022
| (e || window.event).returnValue = ''; | ||
| return ''; | ||
| } | ||
| }) No newline at end of file |
Owner
There was a problem hiding this comment.
Here’s a trailing newline missing
Comment on lines
+5
to
+7
| const inputs = Array.prototype.slice.apply(form.getElementsByTagName('input')); | ||
| const textareas = Array.prototype.slice.apply(form.getElementsByTagName('textarea')); | ||
| const selects = Array.prototype.slice.apply(form.getElementsByTagName('select')); |
Owner
There was a problem hiding this comment.
Can you align those vertically?
| @@ -0,0 +1,21 @@ | |||
| const forms = document.getElementsByClassName('confirmIfUnsavedChanges'); | |||
|
|
||
| window.addEventListener('beforeunload', (e) => { | ||
| if (hasUnsavedChanges) { | ||
| (e || window.event).returnValue = ''; |
Owner
There was a problem hiding this comment.
If you have a relevant web link from your research, please included it as a comment. I remember the pain of research and even with the correct answer couldn’t find the spec right now.
| and $c->stash( | ||
| import_url => $c->uri_for_action( '/browse/recipe/import', [ $recipe->id, $recipe->url_name ] ) ); | ||
|
|
||
| push @{ $c->stash->{js} }, '/js/unsavedChanges.js'; |
Owner
There was a problem hiding this comment.
I like your generic implementation with the <form> class. Do you think we should simply add this to our global script.js to utilize it on any page? 🤔
| [% END %] | ||
|
|
||
| <form method="post" action="[% update_url %]"> | ||
| <form class="confirmIfUnsavedChanges" method="post" action="[% update_url %]"> |
Owner
There was a problem hiding this comment.
I checked out your branch and tested. The JS file was loaded but it had no effect. I made changes and could leave the page without warning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #144 done