0

The problem i'm trying to solve is, I want to have a tap event with a parameter in XML:

I know that, this format will not work. so what is the correct format?

Use case: in a list view you want to open a url

Cheers

1
  • Hi Kevin, welcome to SO. Have you tried anything yet? To get support here, you must show you tried something already, and your research effort. Good luck. Commented May 23, 2016 at 7:48

2 Answers 2

2

Aren't the params set in the XML directly consumable in the js?

Like on a regular tap

var button = args.object;
var param = button.myparam;

Where the XML would have been

<Button myparam="test"

I knew someone who used to pass data around in the XML over just using args.object.bindingContext and using the bound data directly. I THINK this is how he was doing it.

So on a Listview itemTap event I think it'd be something like this

var param = args.view.myparam;
Sign up to request clarification or add additional context in comments.

1 Comment

The problem is that I'm using a listview and passed an object array to the it in which has a URL property, so I'm trying to have a tap or listTap event defined and pass the {{ url }} to it. something like this: `label tap="ontap( {{ url }})" . <- I know that this syntax is wrong, by the way.
1

The easiest way of doing something like this would be to just have the onTap="myTapEvent" on the ListView itself.

Then in the js, you would get the index of the tapped item and fetch it from the original array:

exports.myTapEvent = function(args){
   var tappedItem = myListArray.getItem(args.index);
   var url = tappedItem.url;
}

I am not sure if it is possible to add events to specific items inside the ListView.itemTemplate...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.