Salesforce Asked on December 12, 2021
I’m trying to implement slds tabs and in order to switch between tabs, I need to change the css classes. However, when I try to add or remove classes from the classList, it gives below error in console:
Refused to run the JavaScript URL because it violates the following
Content Security Policy directive: "script-src ‘self’
‘nonce-3744c145-c1b2-ab4c-c4f2-225fd8e53422’ chrome-extension:
‘unsafe-inline’ ‘unsafe-eval’ *.canary.lwc.dev *.visualforce.com
https://ssl.gstatic.com/accessibility/
https://static.lightning.force.com". Note that ‘unsafe-inline’ is
ignored if either a hash or nonce value is present in the source list.
Below is the code snippet:
changeSelectedTab(event){
//remove class for already selected tab
this.template.querySelector('.slds-is-active').classList.remove('.slds-is-active');
}
I also tried,
`this.template.querySelector('.slds-is-active').className= '';
`
Both of these approaches aren’t working. Can someone please help me resolve this.
we dont need "." when we remove or add the class "slds-is-active"
it should be
this.template.querySelector('.slds-is-active').classList.remove('slds-is-active');
here is an example https://developer.salesforce.com/docs/component-library/tools/playground/ycqTBcTN/1/edit
Answered by User6670 on December 12, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP