-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowtaglist.js
82 lines (76 loc) · 2.03 KB
/
showtaglist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var table;
function getdata() {
$.fn.dataTable.ext.errMode = 'none';
table = $('#tags-list').DataTable({
"processing" : true,
"serverSide" : true,
"rowId" : "_id",
"ajax": {
"url":"/tl",
"type":"POST",
},
"columns": [
{
"data" : "tagname"
},
{
"data" : "tagcreator",
},
{
"data" : "tagdate"
},
{
"data" : null,
"sorting" : "false",
}
],
"columnDefs": [{
"targets": 3,
"render": function (data, type, row, meta) {
// console.log(data._id);
data = '<center><a onclick=deleteTag("'+data._id+'") class="btn btn-sm deleteTagbtn" style="background-color:black" ><span class="fa fa-trash" style="color:white;"></span></a></center>'
return data;
}
}],
})
$('#refresh').on('click', function () {
table.ajax.reload(null, false);
});
}
$(document).ready(function() {
console.log("1");
getdata()
})
function deleteTag(id)
{
console.log(event.target);
console.log(id);
$.confirm({
title: 'Delete Tag!',
content: 'Are you sure you want to delete',
draggable: true,
buttons: {
Yes: {
btnClass: 'btn-success',
action: function () {
var obj = {
_id : id,
}
let request = new XMLHttpRequest();
request.open('POST','/deleteTag');
request.setRequestHeader("Content-Type","application/json")
request.send(JSON.stringify(obj));
request.onload = function()
{
alert("tag deleted");
$('#'+id).remove();
}
}
},
No: {
btnClass: 'btn-danger',
action : function() {},
},
}
});
}