alert
, confirm
and prompt
JS-0052 9 if (table.find('td:contains('+user_name+')').length !== 0) {
10 alert('Usuario já adicionado');
11 } else if (sector_id === 0) {
12 alert('Antes de adicionar um usuario, salve o setor');13 } else {
14 let tr = $('<tr class=align-middle></tr>');
15 tr.append('<td id="user_id" value="'+user_id+'">'+user_id+'</td>');''
47 _token: csrf
48 },
49 success: function(data) {
50 alert('Usuario removido com sucesso');51 }
52 });
53 }
34/* A jQuery function that is used to bind an event handler to the "click" JavaScript event, or trigger
35that event on an element. */
36$(document).on('click', '#removeBtn', function(){
37 _confirm = confirm('Tem certeza que deseja remover o usuário?');38 if (_confirm) {
39 $(this).closest('tr').remove();
40 let csrf = $('input[name="_token"]').val();
7 let table = $('#users');
8
9 if (table.find('td:contains('+user_name+')').length !== 0) {
10 alert('Usuario já adicionado');11 } else if (sector_id === 0) {
12 alert('Antes de adicionar um usuario, salve o setor');
13 } else {
JavaScript's alert
, confirm
and prompt
functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation.
Furthermore, alert
is often used while debugging code, which should be removed before deployment to production.
alert("here!");
confirm("Are you sure?");
prompt("What is your name?", "John Doe");
customAlert("Something happened!");
customConfirm("Are you sure?");
customPrompt("Who are you?");
function foo() {
const alert = myCustomLib.customAlert;
alert();
}