How to stop and restart #each loop

Hi I have a gallery site which displays paintings according to selected category (oils, water-color, etc.) “on:click” event.
When this event occurs I create a new filter and want to stop the #each loop and restart it using the new filter, what is the best way to do this?
Thanks for any help