Is it possible to create a search engine with stimulus?

I am trying to create a search engine with stimulus, to replace the jquery datatable component, but I run into a problem and that is that my target name returns undefined
This is my controller:
const application = Stimulus.Application.start();
const { Controller } = Stimulus;

  class extends Controller {
    static get targets() {
      return ['q', 'name'];

    searchTable() {

I have verified my target q, and it works correctly
this is my input template:

 <div data-controller="search">
                    <input type="text" placeholder="Buscar..." maxlength="15" data-action="search#searchTable"
                    <table class="highlight centered">
                                <th>Tipe de Tarea</th>
                                <th>Fecha de Creacion</th>

                                {% for field in object_list %}
                                <td data-search-target="name">{{ }}</td>
                                <td>{{ field.status|yesno:"Visible, No visible" }}</td>
                                <td>{{ field.created_at }}</td>
                                    <a href="#!">editar</a>
                                {% endfor %}

i am using django in my project

Shouldn’t it be console.log(this.nameTarget.value) in singular?

I need multiple values for that reason targets, although I put target the console continues to print undefined

The data-controler directive is missing

if i have the controller

The nameTargets is an array, so you need to access it like an array. Also, each of the name targets will be a <td> in your example. Therefore, there is not value property on them

1 Like