Skip to content

Commit 71344ef

Browse files
committed
add event listener to data table
1 parent e89a33b commit 71344ef

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

manager_dashboard/manager_dashboard/js/project-management.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
function addEventListeners(status) {
2+
$("#projectsTable-"+status).on('click', '.change-status', changeProjectStatus);
3+
$("#projectsTable-"+status).on('click', '.change-isFeatured', changeProjectIsFeatured);
4+
}
5+
16
function getProjects(status) {
7+
console.log('start get project status')
28
var ProjectsRef = firebase.database().ref("v2/projects").orderByChild("status").equalTo(status);
39

410
var tableRef = $("#projectsTable-"+status).DataTable();
@@ -55,22 +61,11 @@ function getProjects(status) {
5561
tableRef.row.add(row_array).draw( false )
5662
});
5763
};
58-
5964
$('.dataTables_length').addClass('bs-select');
6065
console.log('added data table styles')
61-
62-
var btns = document.getElementsByClassName('change-status')
63-
for (let item of btns) {
64-
item.addEventListener("click", changeProjectStatus)
65-
}
66-
67-
var btns = document.getElementsByClassName('change-isFeatured')
68-
for (let item of btns) {
69-
item.addEventListener("click", changeProjectIsFeatured)
70-
}
71-
7266
});
7367

68+
7469
}
7570

7671
function addButton(id, oldStatus, newStatus){
@@ -119,6 +114,8 @@ function updateTableView() {
119114
getProjects("inactive")
120115
getProjects("finished")
121116
getProjects("archived")
117+
118+
console.log('updated table view')
122119
}
123120

124121

@@ -154,8 +151,10 @@ function changeProjectIsFeatured() {
154151
}
155152

156153

157-
getProjects("new")
158-
getProjects("active")
159-
getProjects("inactive")
160-
getProjects("finished")
161-
getProjects("archived")
154+
status_array = ["new", "active", "inactive", "finished"]
155+
156+
for (var i = 0; i < status_array.length; i++) {
157+
status = status_array[i]
158+
getProjects(status)
159+
addEventListeners(status)
160+
}

0 commit comments

Comments
 (0)