var userList;
$(document).ready(function(){
//FUNCTION TO SORT THE LIST A.
var options = {
valueNames: ['teame', 'role', 'name', 'value', 'team' ]
};
userList = new List('players', options);
$('#teams').change(function() {
var selection = this.value;
console.log (selection);
if (selection == "tutte") {
userList.filter();
return false;
}
userList.filter(function(item) {
if (item.values().team == selection) {
return true;
} else {
return false;
}
});
return false;
});
//THIS FUNCTION DETACHES THE ELEMENTS FROM LIST A AND IT APPENDS IT TO THE LIST B
$('.add').click(function() {
var id = this.id;
//$('#your-team').append($("li#p-"+ id + "").html());
$("li#p-"+ id + "").detach().appendTo('#your-team');
//$("li#p-"+ id + "").remove();
userList = new List('players', options);
//userList = new List('players', options);
})
});
你'jsFiddle'不是很直观。如何测试?什么是预期? – melancia 2014-09-26 18:31:10
也许现在好多了! @MelanciaUK – Danny182 2014-09-26 18:42:26
你想对listA进行排序? list.js为你做了什么? – mcgraw 2014-09-26 18:49:04