common.js

define([],
    function() {
        return{
            // Common delete function
            deleteEntity:function(event){
                event.preventDefault();
    // Pop up a confirmation dialog
    var confirmation = confirm('Are you sure you want to delete this?');

    // Check and make sure the venue confirmed
    if (confirmation === true) {

        // If they did, do our delete
        $.ajax({
            type: 'DELETE',
            url: event.data.url + $(this).attr('rel')
        }).done(function( response ) {

            // Check for a successful (blank) response
            if (response.msg === '') {
            }
            else {
                alert('Error: ' + response.msg);
            }

            // Update the table
            var entityType = event.data.type;
            if(entityType ==="offer"){
              window.location.href = '/spotitOffer';
            }else if(entityType ==="venue"){
                window.location.href = '/spotitVenue';
            }else if(entityType ==="subList"){
                window.location.href = '/spotitsubList';
            }else if(entityType ==="review"){
                window.location.href = '/spotitReview';
            }
        });
    }
    else {
        // If they said no to the confirm, do nothing
        return false;
    }

            }
        }
    });

Leave a Reply

Your email address will not be published. Required fields are marked *