0

Why this event not firing? and I have clear the cache and tried every possible thing. So I'm trying to see if the checked is true/false which the value coming from database.

HTML:

<lightning-input data-id="toggle1" type="toggle"
                checked={isChecked}
                onchange={changeToggle}></lightning-input>
....
....
<lightning-input data-id="toggle10" type="toggle"
                checked={isChecked}
                onchange={changeToggle}></lightning-input>

JS:

isChecked(event) {
    const checkboxList = this.data;
    for (const c of checkboxList) {
        debugger;
    }
}

is there any reason for not calling this function isChecked when the page loads?

1 Answer 1

0

checked is a Boolean attribute, not an event handler. All event handlers start with on. You use checked to set the component's state. The checkbox would be checked because you're passing in a function object, which is truthy.

3
  • I realized later thanks for reminding.
    – Nick
    Nov 8, 2021 at 2:17
  • 2
    @NickKahn If I had a dime for every single silly mistake I've made, I'd likely have taken a vacation by now, lol.
    – sfdcfox
    Nov 8, 2021 at 2:32
  • very true and I feel silly when you remind me but you tend to forget if you not using on regular bases :)
    – Nick
    Nov 8, 2021 at 2:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .