How to programmatically trigger doubletap event?


#1

How can I do it? I already looked into ionic forum, google results, and didn’t find anything useful. Also, I already tried triggering dblclick, dbltap, doubletap, doubleClick, and even multiple tap and click events, but nothing seems to work.

I know some events that I used don’t even exist, I was just trying to see if ionic would recognize them somehow. Also, I tried the click events because the app runs just fine in the browser, so I thought it could work in the specs as well.

If it helps, I need this to unit test my feature. I have an ion-list, and when an user double taps an ion-item, it marks the item as checked. My markup currently look like this:

<ion-item on-double-tap="ctrl.toggleProductConfirmation(product)" ...

And my spec, like this:

describe('when checking an item', function() {
  beforeEach(function() {
    this.element.find('ion-item').eq(0).trigger('doubletap');
  });

** specs here **

One last detail: I use phantom JS to run my specs.

Thanks for helping!


#2

http://ionicframework.com/docs/api/utility/ionic.EventController/#trigger


#3

Thanks so much! It worked like a charm.

The docs are a little confusing, so I’ll post my code here to help someone with the same problem:

ionic.trigger('doubletap', { target: this.element.find('ion-item').get(0) });

Because I’m using jquery in my specs, I had to use get(0) to retrieve the DOM element itself, as passing the jQuery object directly didn’t work for me.

Thanks again for the help.


#4

Hello @denislins can you please post your code here…
am in middle of using something that uses double tap but the truth is that am just confuse, nothing is returning.