I have been following some tutorials on here about how to integrate Isotope filtering with CMS by using some custom code to dynamically add a class to an item to allow filtering. I cloned another users Isotope tutorial and added the custom code by another member, but it doesn’t quite seem to work. The bike wheel photos I added are not working with the filtering menu. Can anyone tell me why?
Sorry, should have explained the problem more thoroughly. When you click the ‘bike’ button, it should display only the bike photos. I am trying to get that code to use the category that the photos are assigned to via CMS as their class, and the buttons should filter the photos by the class. However, the bike photos do not seem to have any specific class, and are only displaying under the ‘all’ selection.
It’s this that doesn’t seem to be working:
// add dynamic class
jQuery
( '.w-dyn-item .category' ).each
(
function( index, element )
{
var _this = jQuery( element );
_this.parent().parent().addClass( _this.text().toLowerCase() );
}
);
Ah okay, I guess I don’t understand that. Do I put in my CMS category names, like .bike? Right now I just have a ‘bike’ category. Thanks for your help!
Right, but isn’t this code to make assign each div a the class name dynamically from CMS categories? I’m trying to copy this site, who seems to have it so that the code is assigning each item div a class name based on what category that item was assigned in the CMS. That way, you don’t have to go in and manually assign a category class for each item you add with CMS, and the filtering will still work.
What that code is trying to do is, copy the text content from the h3 tag, make it lowercase, and set it as the class for the .w-dyn-item. If you want to use the same code, then you have to set up your site the same way.
Thanks for your reply. I’ve got mine set up now identical to how Rumi’s is set up, with the h3 tag dynamically connected to the category name, but it still doesn’t seem to work. Here’s my code now:
That is because the code you are using can’t mix dynamic list items with non-dynamic list items.
// init Isotope
var $grid = $('.grid').isotope({
itemSelector: '.item'
});
What the above code is selecting, is all direct descendent (children) elements that has a class of item, from the element with class grid. The items in the dynamic list doesn’t have a class item, AND it is not a child of grid element (is is a “great-grand”-children).
Not sure if you are aware. Mitchell? spelling and #f0f0f0 background with white is only seen by people with perfectly calibrated monitors. Which is like 30% of population.
I have spent a long time trying to figure out why my button filter isn’t working with my CMS, which is structured identically to Sidney’s. The search works fine.
Any help is greatly appreciated! My preview link is below.
Well it seems like it is already working, just that the class selector is so broad, it is affecting ALL the elements with a class button. So that style is printed out once for each button, and the last button’s style is overriding the previous selectors.
You could try changing the button selector to this so that it will affect the button that is in the same category