8. Deleting a recording

 

The functionality of our Voice Memo gadget we have not yet covered is the deletion of a recording. From the list of available recordings a <a> tag with an onclick attribute calling the deleteMemo() function with the correct recording key as a parameter will provide the integration.

 

<a href="javascript:void(0);" onclick="javascript:deleteMemo('put the recording key here');">

 

Our deleteMemo() function only has to make an API call to issue the DeleteRecording command. To prevent the deletion of a memo on an erroneous click from the user, we use the confirm() Javascript function to have a Yes/Cancel dialog box that pops up waiting for the user input before the deletion is issued.

Voice Memo in deleting mode

 

function deleteMemo(id) {

    var answer = confirm('Are you sure you want to delete this memo?');

    if(answer){

        myVox.deleteRecording(id, function(response) {

            // Refresh the list of posts

            getMemos();

        });

    }

}

 

Next, 9. Improving the gadget usability