fredyounan
10/25/2014 - 7:48 AM

gistfile1.js

jQuery('body').on('click', '[data-method="delete"]', function(event) {

    event.preventDefault();
    var confirm_msg = jQuery(this).data('confirm');
    
    var form = jQuery('<form />').attr({
        method : 'POST',
        action : jQuery(this).attr('href')
    });
    
    var spoofer = jQuery('<input />').attr({
        type : 'hidden',
        name : '__spoofer',
        value : 'DELETE'
    });
    
    form.append(spoofer);
    
    if ((confirm_msg && confirm(confirm_msg)) || !confirm_message) {
        form.trigger('submit');        
    }

});