gform/repeater/post_item_delete

Description

The deleteRepeaterItem() function deletes a repeater item when its delete button is clicked. It updates repeater button visibility and dispatches the gform/repeater/post_item_delete event.

Usage

Asynchronous

Use this action when your logic depends on asynchronous operations, such as AJAX requests or delayed UI updates.

document.addEventListener('gform/repeater/post_item_delete', async (event) => {
    const { container } = event.detail;
  // Do something.
});

Synchronous

Use this action when performing immediate cleanup or DOM manipulation after item deletion.

document.addEventListener('gform/repeater/post_item_delete', (event) => {
    const { container } = event.detail;
   // Do something.
});

Parameters

ParameterTypeDescription
deleteButtonHTMLElementThe delete button element inside the repeater item to be removed.

Examples

Listening for a repeater delete event.

document.addEventListener('gform/repeater/post_item_delete', (event) => {
    const { container } = event.detail;
    console.log('Repeater item deleted from container:', container);
});

Placement

Reference the article Adding JavaScript Code to the Frontend of Your Site.

Since

This function was added in Gravity Forms v3.2.0.

Source Code

This function is located in assets/js/src/theme/fields/repeater/index.js