Handlebars page re-rendering after a query doesn’t works

I’m working on a handlebar’s page that show some books. Books can be filtered by title or by author or by city/library.
The page is rendered well the first time, but if I use filters and recall the handler with new parameters, the query is executed well (I can see new books’ list) but handlebar doesn’t update the page with new data

here is a part of my code:

  @Get()
  @Render("ciclo/index")
  async getCicloBooks(
    @Query("ciclo") ciclo,
    @Query("codProv") codProvincia,
    @Query("comune") idComune,
    @Query("title") title,
    @Query("author") author
  ) {
    let books = undefined;
    let comuni = undefined;
    let librariesId = [];
    const libraries = [];
    let data = {};

    this.logger.debug("[getCicloBooks] ciclo: " + ciclo);

    const province = await this.cicloService.getProvince();

    // Titolo
    if (title != undefined) {
      this.logger.log(`[getCicloBooks] per ciclo: ${ciclo} e titolo ${title}`);

      const query = { ciclo: ciclo, title: title };
      books = await this.bookService.getBooksByAdvancedQuery(query);

      // TODO considerare che lo stesso libro può essere in più librerie
      data = {
        pageTitle: `Trovate n librerie che hanno in catalogo ${title}`,
        ciclo: `${ciclo}`,
        books: books,
        libraries: null,
        provincie: province,
        comuni: comuni,
        comune: null,
        author: `${author}`,
        title: `${title}`,
      };
    } // Autore
    else if (author != undefined) {
      this.logger.log(`[getCicloBooks] per ciclo: ${ciclo} e autore ${author}`);

      const query = { ciclo: ciclo, author: author };
      books = await this.bookService.getBooksByCicloAndAuthor(query);

      // TODO considerare che lo stesso libro può essere in più librerie
      data = {
        pageTitle: `Trovate n librerie con libri di ${author}`,
        ciclo: `${ciclo}`,
        books: books,
        libraries: null,
        provincie: province,
        comuni: comuni,
        comune: null,
        author: `${author}`,
        title: `${title}`,
      };
    } // Provincia e comune
    else if (idComune != undefined) {    
      this.logger.log(`[getCicloBooks] ciclo: ${ciclo} id comune ${idComune}`);
      const comune = await this.cicloService.getComune(idComune);
      const allLibraries = await this.cicloService.getAllLibrariesInCities();

      this.logger.log("[getCicloBooks] comune " + JSON.stringify(comune));

      librariesId = [];
      allLibraries.forEach((library) => {
        if (library.comune.id == idComune) {
          libraries.push(library);
          librariesId.push(library.id);
        }
      });
      this.logger.log("[getCicloBooks] ids " + JSON.stringify(librariesId));

      const query = { ciclo: ciclo, id: In(librariesId) };
      // join book e libreria oppure find in table book_library_libreria where libreriaID in [libreriaId])
      books = await this.bookService.getBooksByAdvancedQuery(query);
      // this.logger.log("[getCicloBooks] books " + JSON.stringify(books));

      books.forEach((book) => {
        const libs = [];
        book.library.forEach((l) => {
          librariesId.forEach((id) => {
            if (l.id == id) {
              libs.push(l);
            }
          });
        });

        book.library = libs;
      });

      // this.logger.log("[getCicloBooks] books " + JSON.stringify(books));

      data = {
        pageTitle: `Tutti i libri disponibili per il ciclo: ${ciclo}`,
        ciclo: `${ciclo}`,
        books: books,
        libraries: allLibraries,
        provincie: province,
        comuni: comuni,
        comune: comune,
        author: `${author}`,
        title: `${title}`,
      };
    } else {
      books = await this.bookService.getBooksByCiclo(ciclo);

      data = {
        pageTitle: `Tutti i libri disponibili per il ciclo: ${ciclo}`,
        ciclo: `${ciclo}`,
        books: books,
        libraries: null,
        provincie: province,
        comuni: comuni,
        comune: null,
        author: `${author}`,
        title: `${title}`,
      };
    }

    this.logger.debug("[getCicloBooks] books: " + JSON.stringify(books));

    if (books === undefined) {
      data = {
        title: "Book Store",
        subtitle: `Attualmente non abbiamo nessun libro in catalogo per il ciclo ${ciclo}`,
        books: null,
        province: province,
        comuni: comuni,
      };
    }
    // this.logger.log(books);

    return { viewData: data };
  }

while this is the template code that doesn’t update when new data are given

   {{ log viewData}}
    <ul id="booksPreview">
      {{#each viewData.books}}
      <li style="list-style-type: none">
        <div class="container mt-5">
          <div class="row bt-2" style="margin-top: 20px;">
            <div class="col-lg-3 col-md-2 col-lg-2 mb-2">
              <img src="/covers/{{getCoverImage}}" style="height: 320px; width: 230px;">
            </div>
            <div class="col-lg-7 col-md-8 col-lg-6 mb-2">
              <div class="text-md-start text-black text-capitalize fa-2x">{{title}}</div>
              <div class="text-md-start">Autore {{getAuthor}}</div>
              <div class="text-md-start">Prezzo {{getPrice}} €</div>
              <div class="text-md-start">Abstract {{getDescription}}</div>
            </div>
            <div class="col-lg-2 col-md-2 mb-2">
              <div class="bi-text-left ">
                <a href="/cart/{{id}}" class="btn bg-primary text-white align-bottom">Aggiungi al carrello</a>
              </div>
            </div>
          </div>
        </div>
      </li>
      {{/each}}
    </ul>

And this is one of script’s functions called on serch button click

function onCityClicked(event) {
  event.preventDefault();
  var city = document.getElementById("comuneDropdown").value;
  var ciclo = document.getElementById("ciclo").value;
  console.log(`[onCityClicked] ciclo: ${ciclo} city: ${city} `);

  var uri = `http://${host}:${port}/ciclo?ciclo=${ciclo}&comune=${city}`;
  console.log(`[onCityClicked] uri: ${uri} `);
  $.ajax({
    url: uri,
    type: "GET",
    success: function (result) {
      data = result.viewData;

      console.log("----- SUCCESS -----");
    }, // success
  }); // ajax
}

So, from main page I show the book’s page (default query is executed and template page is rendered successfully), then when I try to change filters, the book’s page is called with choosen filters, the query is excuted well (I check logs) but the template doesn’t update. I got the previous page

I added to original code the <ul id=".."> <li></li> </ul> tags, trying to intercept at runtime some action on id and clean the book’s list before the new render, but I wasn’t able to do

Can someone help me?

Thanks