I have a filter system which filtrate data by category number,
Can i filter that not clicking button, but directly using URL something like "domain.com/?data-filter=2" ???
$('[data-sort-name]').click(function() {
var name = $(this).attr('data-sort-name');
var type = $(this).attr('data-sort-type');
console.log(name + ' ' + type)
$('#main>a').sortElements(function(a, b) {
var av, bv;
av = ($(a).attr('data-' + name));
bv = ($(b).attr('data-' + name));
console.log(av + '///' + bv);
return (
isNaN(av) || isNaN(bv) ?
av >= bv : +av >= +bv
) ?
type == '>' ? -1 : 1 :
type == '>' ? 1 : -1;
});
});
$('[ data-filter]').click(function() {
$('[ data-filter]').removeClass('active');
var type = $(this).addClass('active').attr('data-filter');
if (type == 'all') {
$('#main>a').css('display','block');
} else {
$('#main>a[data-cat]').each(function() {
$(this).css('display', $(this).attr('data-cat').indexOf(type) != -1 ? 'block' : 'none')
})
}
});
});`
here is #menu
<div class="menu-button">
<a type="button" data-filter="all" class="btn" >ALL</a>
<a type="button" data-filter="2" class="btn">Category 1</a>
<a type="button" data-filter="3" class="btn">Category 2</a>
</div>