souce.id to check originating source

I've got a Name List that renders in a popup. Tapping on a Name in the popup sends the name to a function. When I add a New Name to the name list via a Popup Input box, I want the New Name to be sent to the same function as the tap event after it's been entered into local storage. The tap event shows up as event.name and the input box shows up as source.name

In order to do this, I've set up a check source variable that checks the source id like this:
addName function: () {
// . . .stuff to enter the name into storage, then
this.rowItemClicked({name: item});
},

rowItemClicked function: (source, event, inSender, inEvent, inIndex)
var checkSource = source.id;

if (checkSource == "aPP_results") { //comes from the Name List
	var theName = event.name;
};
if (checkSource == undefined) { //comes from the Add Name Input
	var theName = source.name;
// . . . more stuff to process the Name
};
This works but my question is: Is there a better/smarter way to accomplish this?

Comments

  • You can have a handler in the popup that gets the row tap and then sends a different, custom event. I do something like this in CryptoTweets where both key presses and my popup keyboard send a letter guessed event.
Sign In or Register to comment.