Getting name of object that called function

I have been looking everywhere and cannot find a clear answer. I want to create one function that is able to tell the name of the object that called it.

<JavaScript>

	function myFunc(e){
		console.log(e.data.Name);
	}

	module.exports = {
		myFunc
	}

</JavaScript>

<Button ux:Name="TestID" Text="Click me" Clicked="{myFunc}" />

I need to call that same function from several buttons and then run logic depending on what button called it. Can anyone help? I searched for Parameters and a lot of it had to do with passing data between pages but this is the same page.

Hi Jeff,

you’ve almost got it!

<JavaScript>
    function myFunc(args) {
        console.log(args.sender);
    }
    module.exports = {
        myFunc: myFunc
    }
</JavaScript>
<Button ux:Name="TestID" Text="Click me">
    <Clicked>
        <Callback Handler="{myFunc}" />
    </Clicked>
</Button>

When you put a nested Callback inside of a Clicked trigger, your callback function will contain the ux:Name of the trigger container (Button in this case) in args.sender.

That worked! Thank you very much.

One more question. Can you access other values like what the text value is and use it in JS? Like args.Text?

Separate questions deserve separate forum posts.

And no, you would do specifically that using Observables.

Good enough thanks.