I have 2 buttons which each one appears after an AJAX call. This is the code which work in these buttons:
$('#detalles').on('click', 'button', function() {
var id = $(this).data('estatus');
var val = $(this).val();
estatusObj[id](val);
});
And estatusObj have the next:
etc...
'4': function(val) {
if (val === 'no') {
if (confirm('¿Desea eliminar la oportunidad ' + nombre + '?')) {
$.post('oportunidad_query.php', {'id': oportunidad, 'accion': 'delete'})
.done(function() {
$('#detalles').on('dialogclose', function(event, ui) {
location.reload();
});
$('#detalles').dialog({buttons: {'Cerrar': function() {
$(this).dialog("close");
}}
}).html('<h3>¡' + nombre + ' eliminado!</h3>');
});
}
}
else {
alert('hola');
$('#detalles section:first-of-type p+p').html('¿Ajustar cotización?');
$('#detalles').off('click', 'button', function() {
alert('Lo hizo');
});
}
},
The buttons says 'Yes' and 'No'. If 'No', delete data into the database (this works). But when click 'Yes', I want to keep those buttons, but with differents click events. How can do it?