2

I am using Strike Input component as child componet to capture Input Field as below:

<c:strike_input auraId="groupName" value="{!v.group.Name}" type="text" name="Name" label="Group Name" errorMessage="Invalid Group Name"/>

Now in the parent component controller i want to get the value of this input user entered but i am not sure how can i do it. I have registered to an event in the parent component like below:

<aura:handler name="onchange" event="c:strike_evt" action="{!c.strikeInputChanged}" />

And in the parent controller:

strikeInputChanged: function(component, event, helper) {
        var groupObj = component.get("v.groupData");
        groupObj.GroupName =  component.find("inputField").get("v.value");     
        component.set("v.groupData", groupObj);
    },

But component.find("inputField").get("v.value") is returning null. I have also tried with component.find("groupName").get("v.value"); but same result.

2
  • I'm a bit confused, that strike is using their own auraId did you also try using aura:id?
    – itsmebasti
    Nov 28, 2017 at 8:54
  • I think aura:id is with Lightining:input.
    – Umer
    Nov 28, 2017 at 9:59

1 Answer 1

2

Since strike already defined an onchange event:

<!-- strike_input.cmp -->
<aura:registerEvent name="onchange" type="c:strike_evt"/>

you can just use it like this:

<c:strike_input onchange="{!c.strikeInputChanged}" value="{!v.group.Name}"/>

And catch the events Element to get its value like this:

strikeInputChanged: function(component, event, helper) {
    event.getSource().get("v.value");
    ...
},
2
  • Thanks it helps. But i am getting another issue for which i am creating another question.
    – Umer
    Nov 28, 2017 at 10:00
  • I created my next question question
    – Umer
    Nov 28, 2017 at 10:14

You must log in to answer this question.

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