I needed this particular functionality too where the check is done in the selector rather than as another embedded function. Maybe I did more than I needed to, but it means I can now filter date-based stuff with Isotope using a Selector rather than having to write stuff in each filter call.
What I wrote uses the pseudo-selector stuff with jQuery.
// Hides elements with the attribute "index" that is greater than 4
$(':attrGT("index",4)').hide();
// Filter elements using Isotope with the attribute "data-starttime" that is less than or equal to 1234567890
$container.isotope({
filter: ':attrLTEq("data-starttime",1234567890)'
});
Here's the initial code for version 1 (I haven't done ANY extensive testing at all, but so far it has worked for me):
(function ($) {
// Single function to do all the heavy lifting
function attrGTLTSelector(mode, obj, meta) {
var args,
objAttr,
checkAttr,
output = false;
if (typeof meta === 'object') {
args = meta;
} else {
if (meta.match(',')) {
args = meta.split(/["'\s]*,["'\s]*/);
} else {
args = [meta];
}
}
objAttr = parseInt($(obj).attr(args[0]), 10);
checkAttr = parseInt(args[1], 10);
switch (mode) {
case 'lt':
if (objAttr<checkAttr) output = true;
break;
case 'lte':
if (objAttr<=checkAttr) output = true;
break;
case 'gt':
if (objAttr>checkAttr) output = true;
break;
case 'gte':
if (objAttr>=checkAttr) output = true;
break;
}
if (window.console) if (console.log) console.log('attrGTLTSelector', objAttr, mode, checkAttr, output);
return output;
}
// Add custom pseudo selectors to jQuery
$.expr[':'].attrLT = function(obj, index, meta, stack){
return attrGTLTSelector('lt', obj, meta[3]);
};
$.expr[':'].attrGT = function(obj, index, meta, stack){
return attrGTLTSelector('gt', obj, meta[3]);
};
$.expr[':'].attrLTEq = function(obj, index, meta, stack){
return attrGTLTSelector('lte', obj, meta[3]);
};
$.expr[':'].attrGTEq = function(obj, index, meta, stack){
return attrGTLTSelector('gte', obj, meta[3]);
};
}(jQuery));