$(document).ready(function () {
$('.del').click(function () {
// var id = $(this).attr('cmnt-id');
// $.post(url,{
//data sent
//},function(data){
//remove the comment div
//show the confirm box and ask for that question now
confirmBox("Sure wanna delete this?");
$('#console').append('deleted<br />');
//});
});
});
function confirmBox(text) {
var c = $('.confirm');
c.children('.confirm-text').text(text);
c.show();
}
Before deleting upon clicking, I need to show a confirmation message. Once confirmed, the action will be executed by displaying 'delete' in the console.
I prefer not to use any custom browser popups like confirm()
or additional plugins.
However, I'm unsure how to integrate the confirm box functionality effectively. Any assistance would be appreciated!
UPDATE
If there is an element such as:
<button data-id="10" id="send">SEND</button>
jQuery
$('.send').click(){
var data_id = $(this).attr('data-id');
$.post(url{
data_id : data_id
},function(){data}{
$('#console').append('sent');
});
};
In this scenario, how can I implement the confirmbox
function properly?