File: biweeklybudget/flaskapp/static/js/transactions_modal.js


Triggered when a form element for budget splits loses focus. Calls validateTransModalSplits() and updates the warning div with the result.

getObjectValueKey(obj, val)

Return the first property of obj with val as its value, or null.

  • obj – the object to check
  • val – the value to look for
selectBudget(sel_num, budg_id)

Select a budget in a budget select element. If sel_num is null then select in #trans_frm_budget, else it is expected to be an integer and the selection will be made in trans_frm_budget_<sel_num>.

  • sel_num (number|null) – The trans_frm_budget_ Select element suffix, or else null for the trans_frm_budget select.
  • budg_id (number) – The ID of the budget to select.
transModal(id, dataTableObj)

Show the Transaction modal popup, optionally populated with information for one Transaction. This function calls transModalDivForm() to generate the form HTML, transModalDivFillAndShow() to populate the form for editing, and handleForm() to handle the Submit action (using transModalFormSerialize() as a custom serialization function).

  • id (number) – the ID of the Transaction to show a modal for, or null to show modal to add a new Transaction.
  • dataTableObj (Object|null) – passed on to handleForm()

Handler for the “Add Budget” link on trans modal when using budget split.


Generate HTML for a budget div inside the split budgets div.

  • row_num (Integer) – the budget split row number

Ajax callback to fill in the modalDiv with data on a Transaction.


Generate the HTML for the form on the Modal


Custom serialization function passed to handleForm() for Transaction modal forms generated by transModal(). This handles serialization of Transaction forms that may have a budget split, generating data with a budgets Object (hash/mapping/dict) with budget ID keys and amount values, suitable for passing directly to set_budget_amounts().

  • form_id (String) – the ID of the form on the page.

Handler for change of the “Budget Split?” (#trans_frm_is_split) checkbox.


Called when a budget split dropdown is changed. If its amount box is empty, set it to the transaction amount minus the sum of all other budget splits.

  • row_num (Integer) – the budget split row number

Function to validate Transaction modal split budgets. Returns null if valid or otherwise a String error message.