-
-
Notifications
You must be signed in to change notification settings - Fork 995
Refactored corporate-member-join.js
#2043
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
base: main
Are you sure you want to change the base?
Conversation
- Stopped using jQuery - Moved refactored code to `djangoproject.js` - Reused membership level data between event handlers
const level_el = form_el.querySelector('#id_membership_level'); | ||
const levels = [-Infinity, 2000, 5000, 12500, 30000, 100000]; | ||
|
||
amount_el.addEventListener('change', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many ways to implement the functionality for this handler, but this seemed to be the simplest to me.
value = i; | ||
} | ||
|
||
level_el.value = value || ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The empty string sets the select
back to the default selection.
}); | ||
|
||
level_el.addEventListener('change', function () { | ||
amount_el.value = this.value ? levels[Number(this.value)] : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The empty string sets the select
back to the default selection.
Also, I don't think the Number
conversion is strictly necessary here, but I using a string index for an array feels wrong.
djangoproject.js
This code affects two fields on the corporate member page: