如何在JQuery中对数据排序 [英] How to sort data in JQuery
本文介绍了如何在JQuery中对数据排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个滑块,该滑块正在显示来自后端的数据.使用推"功能,它可以根据日期在滑块中显示幻灯片.但是我需要它来根据日期&显示这些幻灯片.状态.
I'm working on a slider which is showing data from the backend. Using the "push" function it is showing slides in the slider according to date. But I need it to show these slides according to date & status.
首先显示未完成状态(btn-危险),然后显示未决状态(btn-成功),然后显示完成状态(btn-警告).
Firstly show incomplete status (btn-danger), after it show pending status (btn-success), and then completed status (btn-warning).
完整代码:
paste.ofcode.org/hmKSwTvaWrjTj3A6rWh464
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();
}
}
推荐答案
您要使用您应该传递一个比较函数,以使sort()
使用您的条件对条目进行正确排序.
You should pass a compare function to have sort()
use your criteria to sort your entries properly.
这篇关于如何在JQuery中对数据排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文