Comments (5)
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.
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.
from stimulus-autocomplete.
Yes the problem is real and apparently, I am not the only one having similar weird issues:
- https://stackoverflow.com/questions/64216804/why-am-i-getting-target-element-missing-error
- https://discuss.hotwire.dev/t/missing-target-element-error/292/5
I even tried this (promising) solution:
but it did not work either. I am wondering if this is Hotwire/Turbo related.
from stimulus-autocomplete.
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)
- Make the query paramater name `q` customizable HOT 2
- error event doesn't fire on 400+ response HOT 1
- Auto-select/highlight the first result on "data load ended" HOT 2
- Suggestion: Allow to use local HTML instead of fetching from the server HOT 3
- Prevent Lighthouse Aria warnings HOT 1
- Data is not being Filtered. HOT 1
- Accessibility
- Feature improve: When mouse move on an option item, it should become the current selected option item. HOT 4
- data-autocomplete-query-param-value not working HOT 4
- New release? HOT 2
- Set "active" class based on what result the user's mouse is over HOT 1
- Combobox with results is hidden when a user goes to another Browser tab HOT 1
- Pre-selected value HOT 1
- Combo Box with client-side fuzzy finder with a static list options
- Question: Handle a 429 Response?
- Support button to open/close results HOT 2
- Improve aria attributes of README example
- CWE-79 (Dangerous dynamic HTML insert detected) reported by Bearer
- Pressing down key should open select HOT 2
- Dont submit form when pressing Enter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stimulus-autocomplete.