# Following on from Adding Unique Class Names

**URL:** <https://meta.discourse.org/t/following-on-from-adding-unique-class-names/37881>\
**Category:** Feature\
**Created:** [January 13, 2016, 11:18am UTC](https://meta.discourse.org/t/following-on-from-adding-unique-class-names/37881 "2016-01-13T11:18:10Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![ccdw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ccdw/32/51564_2.png) [@ccdw](https://meta.discourse.org/u/ccdw)\
**Post date:** [January 14, 2016, 6:51pm UTC](https://meta.discourse.org/t/following-on-from-adding-unique-class-names/37881/9 "2016-01-14T18:51:31Z")

</div>

Thanks but that means the CSS has to be updated every time relevant changes are made to categories - hence why, in my view, it’s better to write class level selectors, and assign the classes within the categories.

> [@riking](#):
>
> If you’re doing selectors on the category list, you can just use this:
> 
> .categories-list .categories {  
> tr[data-category-id=“34”], tr[data-category-id=“32”] {  
> // styles…  
> }  
> tr[data-category-id=“61”] {  
> // styles…  
> }  
> }

Edit:

> [@riking](#):
>
> > [@ccdw](#):
> >
> > So instead I use a jQuery selector to find posts with a target tag that also have images in a Lightbox - this then allows me to insert a gallery control at run time.
> 
> Shouldn’t you be using the decoratePost() hook for this? That lets you get code run once per post display.

Thanks for the suggestion, I’m not familiar with Discourse in depth yet. I am sure I will be able to refactor most of the jQuery stuff once I am, but for now it works very.

---

_[View the full topic](https://meta.discourse.org/t/following-on-from-adding-unique-class-names/37881)._
