diff --git a/app/javascript/src/add_additional_expense.js b/app/javascript/src/add_additional_expense.js index aba5181c55..fc3e88b114 100644 --- a/app/javascript/src/add_additional_expense.js +++ b/app/javascript/src/add_additional_expense.js @@ -1,15 +1,11 @@ /* global $ */ function showAdditionalExpense () { - for (let i = 1; i < 10; i++) { - if ($(`#expense${i + 1}`).is(':hidden')) { - $(`#expense${i + 1}`).wrap('
') - $(`#expense${i + 1}`).removeClass('d-none') - break - } - } + $('.expense-container.d-none').first().removeClass('d-none') } -$(document).on('click', '#add-another-expense', function () { - showAdditionalExpense() +$(() => { // JQuery's callback for the DOM loading + $('#add-another-expense').on('click', function () { + showAdditionalExpense() + }) })