Comments (8)
@ELepolt You have to use the @action
decorator for your this.verifyToken function in the component class or else this === undefined
Example
@action
verifyToken(token) {
console.log(this) //Works
} ```
from ember-render-modifiers.
#OctaneWoes. Thank you so much.
from ember-render-modifiers.
cc @rwjblue this was opened at your suggestion following some chat in octane-migration.
from ember-render-modifiers.
Hey all. Just came upon this today. Is there a more proper way to access this
inside of a component?
// component.hbs
<Input @type="text" @value={{@token}} {{did-insert this.verifyToken @token}}/>
// component.js
verifyToken(token) {
console.log(this) // logs 'undefined'
}
Am I misinterpreting how this addon should be used?
from ember-render-modifiers.
One thing that I've learned here that someone can make use of is this.set()
a value. Even with @action
I've got an error: TypeError: this.set is not a function
.
In my case, I had to save a reference to a node and solved that by using set
from @ember/object
:
// component.js
import Component from '@glimmer/component';
- import { action } from '@ember/object';
+ import { action, set } from '@ember/object';
export default class SomeComponent extends Component {
@action
setFileRef() {
- this.set('fieldRef', document.querySelector('#selector'));
+ set(this, 'fieldRef', document.querySelector('#selector'));
}
}
That might not be the best example because in this case {{ref}}
in nicer. But I'll leave it here anyway.
from ember-render-modifiers.
@tniezurawski You don't need to use set
in a glimmer component, in fact it's not recommended.
Also, you can do this code differently here. As a modifier passes in the element it's attached to so instead of looking through the whole document you can look just within this component.
@action
setFileRef(element) {
this.fieldRef = element.querySelector('#selector'));
}
from ember-render-modifiers.
@dgavey Oh, nice! Thanks for the explanation!
from ember-render-modifiers.
Anyone have a hint on where I could go about adding this ?
Maybe here? https://github.com/emberjs/ember-render-modifiers/blob/master/addon/modifiers/did-insert.js#L61
How could I check that it's an action and not a regular function?
from ember-render-modifiers.
Related Issues (20)
- Document "classic" and native class component examples
- Using with `mut` results in render error HOT 5
- modifierManagerCapabilities is not a function HOT 7
- Modifiers don't seem to work when applied to elements are ember components with `tagName=''` HOT 6
- will-destroy does not invoke re-rendering HOT 5
- did-insert not triggering re-render for tracked changes HOT 4
- @model hash and did-update don't play well together HOT 3
- Support conditional modifiers HOT 3
- improve debugging possibilities of error messages HOT 2
- Uses version of modifier manager capabilities that is deprecated in canary HOT 10
- Undefined is not a function (modifier handing) HOT 1
- Node 12/14 unsupported? HOT 4
- Timing issues without didRender HOT 1
- Cannot install library - Not Found HOT 1
- Unexpected token '.' in Gitlab pipeline HOT 2
- ember-source peerdependencies issue with ember-try - ember-release HOT 7
- Error: Invalid modifier manager compatibility specified HOT 7
- New release with ember v5 support? HOT 1
- Dependency error when using Glint types (`@glint/template`) HOT 1
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 ember-render-modifiers.