我正在开发一个 slider ,它显示来自后端的数据。使用“推送”功能,它可以根据日期在 slider 中显示幻灯片。但我需要它根据日期和状态显示这些幻灯片。
首先显示不完整状态(btn-danger),之后显示待处理状态(btn-success),然后显示完成状态(btn-warning)。
完整代码:
paste.ofcode.org/hmKSwTvaWrjTj3A6rWh464
代码:
function handleSubmit(command) {
if(command === 'meeting') {
let meetingFormValue = getMeetingFormValue('.create-meeting-form');
httpService.post('http://localhost:3000/meeting/create', meetingFormValue)
.then(response => {
meetings.push(response);
setMeetingCarausel();
}).catch(ex => {
console.log('Error');
console.log(ex);
})
// close the form
$('.create-meeting-form').stop().slideToggle();
}else if(command === 'task') {
//attendees
const taskFormValue = getTaskFormValue('#createTaskForm');
httpService.post('http://localhost:3000/meeting/taskList/create', taskFormValue)
.then(response => {
tasks.push(response);
setTasksCarausel();
}).catch(ex => {
console.log(ex);
});
// close the form
$('.create-task-form').stop().slideToggle();
}
}
最佳答案
您想使用Array.prototype.sort() .
您应该传递一个比较函数,让 sort()
使用您的条件对条目进行正确排序。
关于javascript - 如何在 JQuery 中对数据进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60500585/