Skip to content

Commit

Permalink
limited click event to button, cleaner additional expense show
Browse files Browse the repository at this point in the history
  • Loading branch information
FireLemons committed Aug 31, 2023
1 parent 2a4ccb0 commit a1bdb6e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions app/javascript/src/add_additional_expense.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
/* global $ */

function showAdditionalExpense () {
for (let i = 1; i < 10; i++) {
if ($(`#expense${i + 1}`).is(':hidden')) {
$(`#expense${i + 1}`).wrap('<li></li>')
$(`#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()
})
})

0 comments on commit a1bdb6e

Please sign in to comment.