0

I was reading following document (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ui_events.htm), but there is nowhere specified how to find out, which UI component triggers the event...we can only specify handler for it.

Scenario: I have lot of ui:inputNumber components in table and I need an event to send its value on change to another component.

Is it possible to find out in handler, which UI components triggered the "change" event from ui:inputNumber?

2

lets say you have multiple ui:inputNumber

<aura:component >
    <aura:attribute name="whichButton" type="String" />

    <p>You clicked: {!v.whichButton}</p>

    <ui:inputNumber aura:id="button1" label="Click me" change="{!c.nameThatButton}"/>
    <ui:inputNumber aura:id="button2" label="Click me too" change="{!c.nameThatButton}"/>
</aura:component>

In js you can get aura:id by

({
    nameThatButton : function(cmp, event, helper) {
        var whichOne = event.getSource().getLocalId();
        console.log(whichOne);
        cmp.set("v.whichButton", whichOne);
    }
})

refernce : https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_which_button_pressed.htm

0

event.getSource().get("v.name") will solve your problem.

For more details, check the link below:

http://hellosnl.blogspot.in/2017/05/which-button-was-pressed.html

  • This post reads as mostly an attempt to drive traffic to your blog. If the posted link answers the question, please cite the relevant content here. Links can go dead over time, so a quality answer will stand on its own without anyone ever needing to click the link. – Adrian Larson Jul 17 '17 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.