I'm using filterify (http://luis-almeida.github.io/filtrify/) plugin to filter some divs. Now what i'm trying to do is get the data attributes from a
element and match it with the target div element.
When I enter the values manually it works fine, example, ft.trigger({ type : ["red"] }
but when i'm trying to make it dynamic and mix it with variables that's where it fails.
My script look something like this:
$(function(){
var ft = $.filtrify("boxes");
$("#filter_nav a").click(function(e) {
e.preventDefault();
// coding the values manually works
// ft.trigger({ type : ["red"] }
var customData = $(this).data()
for (var key in customData) {
ft.trigger({ key : [customData[key]] });
// should return something like ft.trigger({ type : ["red"] });
}
});
});
HTML
<ul id="filter_nav">
<li><a href="#" data-type='red' >Red</a></li>
<li><a href="#" data-type='yellow' >Yellow</a></li>
<li><a href="#" data-type='blue' >Blue</a></li>
<li><a href="#" data-type='green' >Green</a></li>
<li><a href="#" data-progress='20' >20</a></li>
<li><a href="#" data-progress='40' >40</a></li>
<li><a href="#" data-progress='60' >60</a></li>
<li><a href="#" data-progress='80' >80</a></li>
</ul>
<div id="boxes">
<div data-type='red' data-progress='20' class="box red"></div>
<div data-type='yellow' data-progress='40' class="box yellow"></div>
<div data-type='blue' data-progress='60' class="box blue"></div>
<div data-type='red' data-progress='20' class="box red"></div>
<div data-type='green' data-progress='80' class="box green"></div>
<div data-type='yellow' data-progress='40' class="box yellow"></div>
<div data-type='blue' data-progress='60' class="box blue"></div>
<div data-type='red' data-progress='20' class="box red"></div>
</div>
I'm suspecting that my setup here is wrong
ft.trigger({ key : [customData[key]] });
more about trigger method: http://luis-almeida.github.io/filtrify/trigger.html
Can you help me?
Thank You!