Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add form submit events to several backbone views #2244

Merged
merged 4 commits into from
Jan 17, 2018

Conversation

tvdeyen
Copy link
Member

@tvdeyen tvdeyen commented Sep 29, 2017

Lots of our backbone based table rows do have input fields. Users are used to be able to submit changes by hitting the enter key inside a form field.
This is default browser behaviour and should be supported by all our backbone based table row views.

@tvdeyen tvdeyen requested a review from jhawthorn September 29, 2017 22:53
@tvdeyen tvdeyen added changelog:solidus_backend Changes to the solidus_backend gem type:enhancement Proposed or newly added feature UI labels Sep 29, 2017
@tvdeyen tvdeyen force-pushed the backbone-form-submit-events branch from 73320c3 to 0b9273b Compare September 29, 2017 22:57
@mtomov
Copy link
Contributor

mtomov commented Oct 2, 2017

Thanks!

var code = e.keyCode || e.which;
if (code === 13) {
this.$el.closest('form').submit();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather find a different solution to this. I believe I've found the issue and we should address it in a separate PR. It's not a backbone issue.

The is that the "Add" buttons from the Tiered calculators, which aren't submit buttons, but their disabled state causes chrome to not submit the form on "Enter". This can probably be better solved by making these buttons an <a class="btn" instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. I’m more than happy to remove this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted the buttons into anchors. The actual problem was that hitting the enter key added new tiers and that prevents the form from being submitted.

@tvdeyen tvdeyen self-assigned this Oct 18, 2017
@tvdeyen tvdeyen added the WIP label Oct 18, 2017
@tvdeyen tvdeyen force-pushed the backbone-form-submit-events branch from 0b9273b to d3a7f9a Compare November 25, 2017 21:21
@tvdeyen
Copy link
Member Author

tvdeyen commented Nov 25, 2017

@jhawthorn review again, please

@tvdeyen tvdeyen removed the WIP label Nov 25, 2017
@tvdeyen tvdeyen removed their assignment Nov 25, 2017
@tvdeyen tvdeyen force-pushed the backbone-form-submit-events branch from d3a7f9a to 75b52f3 Compare November 26, 2017 21:05
In order to be able to submit the payments form with the enter key we wrap the input field in a form and use the form submit event in addition to the click event of the save button.
In order to be able to submit the form with enter key in addition to the click event on the save button we wrap the input field in a form.
Buttons block the surrounding form from being submitted by enter key.
Instead the enter key leads to tiers being added. Using anchors instead.
@tvdeyen tvdeyen force-pushed the backbone-form-submit-events branch from 75b52f3 to 6162a54 Compare January 10, 2018 08:22
@tvdeyen
Copy link
Member Author

tvdeyen commented Jan 10, 2018

Rebased with latest master and fixed conflicts

@jhawthorn jhawthorn merged commit d30c9d7 into solidusio:master Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_backend Changes to the solidus_backend gem type:enhancement Proposed or newly added feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants