One Page App With Drupal 8 and Vue.js Episode 5

Making Filter Dynamic

In this episode of Drupal 8 and Vue.js learn how to make our genre filter dynamic. And for that we are going to use jQuery.

Our genre filter from the last episode is ok, but it’s not great. First of all it’s hard coded, so that is not good, we don’t want to add new values to it every time we add a movie with a new genre.

And secondly there are some genres in it that we don’t even have in our movie list. So if we choose that, we get an empty list. So that is also not the coolest.

We are going to fix all those problems using jQuery. First we are going iterate through our movies, to get available genres. And then we are going to make an array with unique genre values that we can display in our option list.

At the end we will have completely dynamic filter with all the available genres and it will populate dynamically as we add new movies and new genres.

Wanna ask a question about video?

Like This Video?

Support it by sharing it ;)

© Watch And Learn,2024