@Ali-Hussain I'm doing something similar to this but with the borders. It would be easy to adapt this so that it sets the background instead.
It's essentially jQuery doing the legwork, but works perfectly.
When I create a new subcategory via the admin panel, the parent category doesn't load well any more : the loading stops at about 2/3 of the loading bar.
When I use the API for creating a new subcategory, I get the same problem. The insertion with my PHP program works, and the sub-categories are visible in the admin panel, but the parent category doesn't load completely anymore.
Do you have any idea concerning this problem ?
Thank you.