You need to sign in to do that
Don't have an account?
Stefaan Somers 11
Modify track property trhough this-variable in context of field
I have a Lightning component with the following property
@track disabled = false;
I now also have the following code :
let allInputFields = this.template.querySelectorAll('lightning-input'); allInputFields.forEach(function(input){ input.addEventListener('focus', function(event) { this.value=''; this.className = 'input-focus'; //this.disabled=true; },false);
When I execute the code in bold, it's not acting on the @track property. How can I do this?
@track disabled = false;
I now also have the following code :
let allInputFields = this.template.querySelectorAll('lightning-input'); allInputFields.forEach(function(input){ input.addEventListener('focus', function(event) { this.value=''; this.className = 'input-focus'; //this.disabled=true; },false);
When I execute the code in bold, it's not acting on the @track property. How can I do this?
Check out the example over below link to understand more about tracked properties in LWC:
https://rajvakati.com/2019/01/01/tracked-properties-in-lightning-web-component/
Hope above information helps. Please mark as Best Answer so that it can help others in future.
Thanks.