Support

Account

Home Forums Add-ons Repeater Field Alert when deleting a repeater row

Helping

Alert when deleting a repeater row

  • Hello,

    Has anyone added an alert that would prompt the user with an “Are you sure…” alert when clicking on the “-” to remove a repeater row.

    Any direction is appreciated.

    thanks!

  • Hi @gary_williams

    In order to achieve such a feature, try out the following sample snippet for the same

    <?php
    
    add_action('acf/input/admin_head', 'my_acf_admin_head');
    
    function my_acf_admin_head() {
    	
    	?>
    	<script type="text/javascript">
    	(function($) {
    		
    		acf.add_action('ready', function(){
    			
    			$('body').on('click', '.acf-repeater-remove-row', function( e ){
    				
    				return confirm("Delete row?");
    				
    			});	
    			
    		});
    		
    	})(jQuery);	
    	</script>
    		
    	<?php	
    	
    }
    
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Alert when deleting a repeater row’ is closed to new replies.