ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

No click event on icon

Open piernik opened this issue 12 years ago • 18 comments

If I add only icon it doesn't recieve click events on android 4.1: <i class="ion-help-circled" ng-click="alert('none');"></i> or <a ng-click="alert('none');"><i class="ion-help-circled"></i></a>

This recieves event on text only: <a ng-click="alert('none');"><i class="ion-help-circled"></i> Text</a>

piernik avatar May 21 '14 09:05 piernik

Try:

<a class="button button-clear" ng-click="something()">
  <i class="icon ion-help-circled"></i>
</a>

ajoslin avatar May 21 '14 12:05 ajoslin

That works but makes padding that I don't want to

piernik avatar May 21 '14 13:05 piernik

piernik, were you able to remove the padding?

perrygovier avatar May 28 '14 16:05 perrygovier

I've iggnored icon and set text as well <a ng-click="alert('none');">Get help <i class="ion-help-circled"></i></a> so problem is not solved, but I do know how to get rid of padding ;)

piernik avatar May 28 '14 18:05 piernik

I believe this is because the actual image is a pseudo element. @adamdbradley would our click modifications fire on a pseudo element?

@piernik, could you put together a quick codepen for us to test against?

perrygovier avatar May 29 '14 19:05 perrygovier

Looks like its a quirky Android 4.1 thing. I was able to replicate it on 4.1, but not 4.2. In your case, since you do not want to use a button and override the padding, you can instead add a background color and then the whole element is clickable. Thanks

adamdbradley avatar Jun 03 '14 03:06 adamdbradley

The only thing that worked for me was to was to change the event to ng-mouseover. Works fine on mobile devices, does not work in a browser (ionic 1.2.5; Chrome 32 on Ubuntu 14.04).

fafk avatar Oct 28 '14 07:10 fafk

How about using "on-tap"?

ghost avatar Jan 15 '15 09:01 ghost

I can confirm this while testing in Chrome. Even when wrapping with other elements, the parent elements will not fire.

tannerlinsley avatar Jan 24 '15 00:01 tannerlinsley

I'm having this issue as well. Are you guys doing an e.preventDefault() on <i> targets? Tested on beta 14 nigthly 995

Update: I have it working replacing the parent <label> with a <div>

As @mhartington explains here: http://forum.ionicframework.com/t/cannot-tap-click-a-clear-search-icon-inside-an-input-label/4237/7

Thing to remember about how ionic deals with setting focus to inputs:

We use labels to to watch for any tap events, then check to see if that label has an input inside of it. If so, set focus to the input.

To use a button along the input, swap the label to a span or div, your ng-clicks will work fine after that.

FdezRomero avatar Feb 09 '15 01:02 FdezRomero

I was able to get this working wrapping the icon with a and the on-tap zhuhu mentioned earlier:

<span on-tap="clearSearch()"><i class="icon ion-close"></i></span>

aiouy avatar Apr 22 '15 16:04 aiouy

I'd like to put a big green checkmark next to the comment from FdezRomero. Thanks!

cosnofski avatar Oct 02 '15 22:10 cosnofski

Got same issue today. Changing event handler to 'on-tap' worked.

ladmerc avatar Jun 20 '16 09:06 ladmerc

'on-tap' works. Kudos

Emmarex avatar Jul 15 '16 10:07 Emmarex

on-tap did not work for me. Had to use ng-click for it to work on Android 4.1.2.

<a ng-click="substract()"><i class="icon ion-ios-minus"></i></a>

miparnisari avatar Sep 26 '16 19:09 miparnisari

@FdezRomero Changing the label element to a div fixed it for me. ty

jackvial avatar Sep 06 '17 19:09 jackvial

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Sep 02 '18 04:09 ionitron-bot[bot]