K
K
kimqar_ver2020-04-25 19:05:06
JavaScript
kimqar_ver, 2020-04-25 19:05:06

Filtering products in js without reloading the page?

How to filter products by category without reloading the javascript page? For example, there are sections "computers", "vacuum cleaners", "irons", and by clicking on a category, only products that are in this section should be shown, while others should be hidden

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arseny, 2020-04-25
@kimqar_ver

1. If you need to filter only what came to the page, you can take filtering by class and show only those where classList.contain.
1.2 Or hang up the date parameters.
1.3 Either load them immediately in JS and draw them with JS.
1.4 And it's even better to drive into a module which one from a JS framework that has reactivity.
And if you receive data from the API, then the same approach, only modified by requests to the service, for example.

A
alex4answ, 2020-04-25
@alex4answ

Yes, a million ways,
at least assign classes with categories, and then filter, at least re-render A
bunch of ways

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question