$(function () {

  	$('.button_delete_modal').on('click', function() {

  		var id = $(this).data("id"); 
  	
  		$('#delete_modal').modal({
  			closable: false,
		    onApprove : function() {
		    	sendDelete(id);
		    }
  		}).modal('show');  
  	});		   

  	function sendDelete(id) {

	    var data = {id_local : id};

        $.requestApi('/sucursal/eliminar', data, 'POST', function (resolve) {
	        if (resolve) {
                if (resolve.message === "success") {
                    $('[data-table="'+id+'"]').remove();         
                }
	            $.showMessages(resolve);
	        }
	    });
        
        return false;
	};      


});	