2

I am using event.get.source, to get the text of inputcheckbox when it is clicked. But i am getting error in the [Cannot read property 'get' of undefined]. Previously it was working fine.

Cmp

<ui:inputcheckbox aura:id="taskCheckBox1" text="{!v.accountDetail.BillingStreet}" label="{!v.accountDetail.BillingStreet}" change="{!c.updateCheckboxes1}" />

<ui:inputcheckbox aura:id="taskCheckBox2" text="{!v.accountDetail.BillingCity}" label="{!v.accountDetail.BillingCity}" change="{!c.updateCheckboxes1}" />

JS

updateCheckboxes1: function(component, event) {
    var id = event.source.get("v.text");

    //  alert('id account field value' + id);
    if (event.source.get("v.value")) {
        // Checkbox is checked - add id to checkedAccInfo
        if (component.get("v.checkedAccInfo").indexOf(id) < 0) {
            component.get("v.checkedAccInfo").push(id);
        }
    } else {
        // Checkbox is unchecked - remove id from checkedAccInfo
        var index = component.get("v.checkedAccInfo").indexOf(id);
        if (index > -1) {
            component.get("v.checkedAccInfo").splice(index, 1);
        }
    }
},

1 Answer 1

5

In controller you using event.source to get text associated with ui:inputcheckbox component not use like this event.source.get("v.text"); instead you use event.getSource()

var id = event.getSource().get("v.text");

You must log in to answer this question.

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