question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

controller target access problem

See original GitHub issue

hey,

is it possible to have multiple data-content-loader-url on one controller for different elements amd also data-targets. like that

<div data-controller="myController" data-content-loader-url="/api/test">
   <select data-controller="myController" data-content-loader-url="/api/loader-1" data-target.loader1 >
   </select>
   <select data-controller="myController" data-content-loader-url="/api/loader-2" data-target="myController.loader2">
   </select>
   <select data-controller="myController" data-content-loader-url="/api/loader-3" data-target="myController.loader3">
   </select>
</div>

i have created the static methog like that:

static get targets() {
			return ["loader1","loader2","loader3"]
		}

when i try to access the the input variables like this.:

let loader 3 = this.loader3Target.value

i get the following error

Error invoking action "click->myController#saveLoader"

 
Error: Missing target element "myController.loader3"
Stack trace:
get@http://localhost:3000/js/stimulus.umd.js:5:1548
saveProjectDetails@http://localhost:3000/js/main.js:326:8
E</t.prototype.invokeWithEvent@http://localhost:3000/js/stimulus.umd.js:5:3143
E</t.prototype.handleEvent@http://localhost:3000/js/stimulus.umd.js:5:2684
 

It worked if i had different contrller for the targets and the content url loader

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
javancommented, Apr 9, 2018

Every controller+identifier pairing creates a new scope, which allows nested controller elements to function independently. Nested controller elements are isolated from parent elements with the same identifier. For example:

<div id="a" data-controller="content">
  <div id="b" data-controller="content" data-target="content.view">
    <div data-target="content.view"></div>
  </div>
</div>

The controller for b will have 2 viewTargets and a will have 0 (because they both belong to b’s scope).

0reactions
rupasixcommented, Apr 9, 2018

My point was that propably you demand all variables (loader1, loader2 and loader3) on your action saveLoader but you have 3 instances of your controller “myController”, each one with different loader. So if i’m right you have something like that: <select data-controller="myController" data-content-loader-url="/api/loader-1" data-target="myController.loader1" > </select> and in your saveLoader: let loader3 = this.loader3Target.value which should end with error Missing target element "myController.loader3" because you have only loader1.

Is that your case? If not - i don’t understand what you want to achieve and can’t help you. Can you share with us your “MyController” code and full HTML where that controller is used?

Read more comments on GitHub >

github_iconTop Results From Across the Web

controller target access problem · Issue #142 · hotwired/stimulus
So, you demand myController.loader3Target on method saveLoader() using DOM element without data-target="myController.loader3" , am i right?
Read more >
Target account name is incorrect - Windows Server
This can occur when the target server principal name (SPN) is registered on an account other than the account the target service is...
Read more >
How to fix 8 common remote desktop connection problems
2. Firewall problems · Open the Control Panel by entering Control at the Windows Run prompt · Click System and Security · Click...
Read more >
Target Access Problems by Authentication Protocol - Tenable
1) A plugin tried to access a resource that requires a special privilege level such as NT_AUTHORITY on Windows. · 2) Environmental issues...
Read more >
Login Failure Target Account Name is Incorrect - Spiceworks
... to access using its FQDN i.e. Server-A Error : Login Failure Target ... target account name is incorrect error is if a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found