Search code examples
repeatertapnativescript

Nativescript StackView on Listview onClick


I have this repeater,

<Repeater.itemTemplate>          
    <StackLayout tap="tapEvent" index='im-an-index'>
    <Image src="{{src}}" stretch="aspectFill" />
   </StackLayout>
</Repeater.itemTemplate>  

I want to get the index on my tap event. My JS looks like this,

function tapEvent(args) {
    var target = args.object;
  var index = target.index;
    console.log(index);
}
exports.tapEvent = tapEvent;

On console.log, I only get {} .. How can I get the index attr of the tapped stacklayout? Thanks.


Solution

  • I think that there was a bug and in some cases a wrong object is passed to args.object. You can try to get the stack with args.view.