[英]on option select, show/hide table row and sort
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/ 我在这里有一个完整的工作示例: 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. 并且具有
row-disabled
的类的row-disabled
应位于表的末尾。 I am using Bootstrap Sortable , but couldn't figure out how to do it. 我正在使用Bootstrap Sortable ,但无法弄清楚该怎么做。 So everytime I click in an option in the selectbox it should re-order the table.
因此,每当我在选择框中单击一个选项时,都应该对表重新排序。
Your function containsAny
should be 您的功能
containsAny
应该
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);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.