Coder Social home page Coder Social logo

Comments (5)

drnic avatar drnic commented on May 29, 2024

I can't think of anything.

Is there any possibility you have css or js that removes that <ul class="list-group" data-autocomplete-target="results"></ul> element, or that it doesn't exist yet, before the controller connect() is run?

The connect() method starts with mutating the this.resultsTarget, so it might not be specifically an issue with that node, but a more general issue:

  connect() {
    this.resultsTarget.hidden = true

What I mean is, since this first line fails, we can't confirm that the controller is happy about the other targets either; and the issue might be elsewhere in the DOM/javascript loading sequence.

from stimulus-autocomplete.

AlainPilon avatar AlainPilon commented on May 29, 2024

Your explanation makes sense, but I can't figure out why/how the connect call would be run before the HTML is rendered. It is all static code. I will try on another page with a simpler setup and see how it goes.

I will close the issue since it seems to be specific to my setup. Thx

from stimulus-autocomplete.

drnic avatar drnic commented on May 29, 2024

from stimulus-autocomplete.

AlainPilon avatar AlainPilon commented on May 29, 2024

Yes the problem is real and apparently, I am not the only one having similar weird issues:

I even tried this (promising) solution:

but it did not work either. I am wondering if this is Hotwire/Turbo related.

from stimulus-autocomplete.

rafaelmadeira avatar rafaelmadeira commented on May 29, 2024

I was just having this same issue trying to implement this auto-growing textarea.

It worked perfectly until I tried to submit a form with validation errors. Then the auto-growth broke and I got the Error: Missing target element "auto-grow-textarea.input".

I'm using Rails 7 with Turbo and forms are submitted via AJAX so I figured the lack of actual reloading was somehow messing with the process. I'm not sure exactly what information gets persisted/reloaded during these requests, but I figured the textarea had to be part of it, so I moved the controller declaration from the parent element to the <textarea> element itself. It worked. In the end, it looked like data: { controller: "auto-grow-textarea", action: ....

(I know this is not related to stimulus-autocomplete, just sharing in case it might help others who end up here with the same problem.)

from stimulus-autocomplete.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.