This block of code verify if all of codes is checked. I am looking for a way to check if at least one of the codes is checked, instead.
function containsAny(needles, haystack){
for(var i = 0 , len = needles.length; i < len; i++){
if($.inArray(needles[i], haystack) == -1) return true;
}
return false;
}
I have a full working example here: http://jsfiddle.net/v7wt5eop/
How to see this behavior:
And the rows that are with the class row-disabled
should be at the end of the table. I am using Bootstrap Sortable , but couldn't figure out how to do it. So everytime I click in an option in the selectbox it should re-order the table.
Your function containsAny
should be
function containsAny(needles, haystack){
for(var i = 0 , len = needles.length; i < len; i++){
if($.inArray(needles[i], haystack) != -1) return false;
}
return true;
}
To sort every time you check/uncheck
$('.selectpicker').on('change', function() {
var list = [];
$('.selectpicker :selected').each(function(i, selected) {
//Removed the irrelevant codes
});
$('.CodeCheck').each(function() {
//Removed the irrelevant codes
});
el = $(".table tbody tr.row-disabled:first-child");
$(".table tbody tr").not(".row-disabled").each(function() {
$(this).insertBefore(el);
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.