Yes, placing it there within the init function, after the setTimeout block, will work.
Here's how your init function would look with that line added:
javascript
const init = () => {
const attachPoint = document.querySelector(".container #pricing-table-content h4");
if (!document.querySelector(`.${ID}__multistep-form`)) {
attachPoint.insertAdjacentHTML("afterend", multiStepForm(ID));
}
setTimeout(()=>{
const multiStepFormInput = document.querySelectorAll(`.${ID}__multistep-form input`);
if(multiStepFormInput.length > 0) {
multiStepFormInput.forEach((input) => {
input.checked = false;
});
}
}, 2000); // Semicolon was missing here, added for good practice
// Add your line here:
const pricingContent = document.querySelector('#pricing-table-content');
if (pricingContent) {
pricingContent.style.maxWidth = '80%';
}
};
Explanation of why this works and a small refinement:
Timing: The init function is called early in the activate process. By placing the line here, you ensure the style is applied when the component is being initialized.
setTimeout: The setTimeout block you have clears the checkboxes. The line setting maxWidth will execute after the setTimeout is scheduled, but not necessarily after the setTimeout callback itself has finished (due to the asynchronous nature of setTimeout). However, for setting a style like maxWidth, this timing is generally fine as it doesn't depend on the checkboxes being cleared.
Refinement (Null Check): I've added a small check: