Skip to content

Commit e444a76

Browse files
adamzappauloxnet
authored andcommitted
Made selectors more specific
1 parent 45c6a62 commit e444a76

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

djangoproject/static/js/djangoproject.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,30 +185,34 @@ document.querySelectorAll('.btn-clipboard').forEach(function (el) {
185185
})();
186186

187187
// Update donate button text on fundraising page based on interval selection
188-
document.getElementById('id_interval').addEventListener('change', function () {
189-
const text = this.value === 'onetime' ? 'Donate' : `Donate ${this.value}`;
188+
document
189+
.querySelector('#donate #id_interval')
190+
.addEventListener('change', function () {
191+
const text = this.value === 'onetime' ? 'Donate' : `Donate ${this.value}`;
190192

191-
document.getElementById('donate-button').value = text;
192-
});
193+
document.getElementById('donate-button').value = text;
194+
});
193195

194196
// Manage custom donation amount input on fundraising page
195-
document.getElementById('id_amount').addEventListener('change', function () {
196-
if (this.value !== 'custom') {
197-
return;
198-
}
197+
document
198+
.querySelector('#donate #id_amount')
199+
.addEventListener('change', function () {
200+
if (this.value !== 'custom') {
201+
return;
202+
}
199203

200-
const input_el = document.createElement('input');
204+
const input_el = document.createElement('input');
201205

202-
input_el.setAttribute('type', 'number');
203-
input_el.setAttribute('name', 'amount');
206+
input_el.setAttribute('type', 'number');
207+
input_el.setAttribute('name', 'amount');
204208

205-
const custom_donation_el = document.querySelector('.custom-donation');
209+
const custom_donation_el = document.querySelector('.custom-donation');
206210

207-
custom_donation_el.appendChild(input_el);
208-
custom_donation_el.style.display = 'block';
211+
custom_donation_el.appendChild(input_el);
212+
custom_donation_el.style.display = 'block';
209213

210-
this.remove();
214+
this.remove();
211215

212-
input_el.focus();
213-
input_el.value = '25';
214-
});
216+
input_el.focus();
217+
input_el.value = '25';
218+
});

0 commit comments

Comments
 (0)