Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection repeat and hrefs #1674

Closed
mhartington opened this issue Jun 25, 2014 · 11 comments
Closed

Collection repeat and hrefs #1674

mhartington opened this issue Jun 25, 2014 · 11 comments
Assignees
Milestone

Comments

@mhartington
Copy link
Contributor

If you are evaluating an express with ng-href with collection repeat, it causes some issues.

 ng-href="{{(0 < $index) ? '#/detail/' + pet.id : ''}}"

http://codepen.io/mhartington/pen/dfLkb

This first item will not have a link, but if you scroll down item 25, click it, go back, then scroll up to first item and click it, you will get a link.

But if you use href instead, everything works fine.

 href="{{(0 < $index) ? '#/detail/' + pet.id : ''}}"

http://codepen.io/mhartington/pen/GDBdr

@perrygovier
Copy link
Contributor

Clarification, the link working on the first item is the bug. After scrolling and going back to the top, I often find it links to the 16th - 20th item (depending on velocity).

@perrygovier perrygovier self-assigned this Jun 25, 2014
@hiroyachiba
Copy link

It seems this bug happens on ionic beta.7 and later.
The bug doesn't happen on beta.6 and before.
I think ion-item's attributes needs to be cleared before it's reused.

@ajoslin
Copy link
Contributor

ajoslin commented Jul 8, 2014

I see.. it's because if ng-href evalutes to a falsy value, the href will stay the same as it was before.

We can add special cases for ng-src and ng-href.

@ajoslin
Copy link
Contributor

ajoslin commented Jul 8, 2014

angular/angular.js#6986 is a pull request to fix this. Until that's merged, we'll create a patch on our end.

@ajoslin ajoslin closed this as completed in 208ef13 Jul 8, 2014
@hiroyachiba
Copy link

Thank you for looking into this issue, but I guess the problem still happens in slightly modified case.

The change fixes if the list is using
<div class="list">
<a class="item">
as in http://codepen.io/hryc/pen/LoDEe.

But the problem still happens if the list is using
<ion-list>
<ion-item>
as in http://codepen.io/hryc/pen/kLlfg.
ion-item creates a tag as its child and the a tag contains previous href value.
repeat

@mhartington
Copy link
Contributor Author

Going to reopen this one.

Using ion-item instead of <a class="item"> still causes the issue.

http://codepen.io/mhartington/pen/baLyx

@mhartington mhartington reopened this Jul 11, 2014
@hiroyachiba
Copy link

I guess this change will fix this issue.

ionic-angular.js, around line 657
CollectionRepeatDataSource.prototype.detachItem()

    this.backupItemsArray.push(item);
    item.element.css(ionic.CSS.TRANSFORM, 'translate3d(-2000px,-2000px,0)');
    // BEGIN
    var $a = item.element.find('a');
    if ($a) {
      $a.removeAttr('href');
      $a.removeAttr('ng-href');
    }
    // END

@adamdbradley adamdbradley added this to the 1.0.0-beta12 milestone Jul 28, 2014
@ajoslin
Copy link
Contributor

ajoslin commented Aug 11, 2014

Fixed.

@mica16
Copy link

mica16 commented May 7, 2015

Using ionic 1.0rc4, when I type a french phone number in an item of collection-repeat: 0633445566, iOS transforms it into a Phone link and the bug happens.
It's very annoying since my zone is a Chat and as long as scroll down, the link moves ..like if someone else gave this number.

@mhartington
Copy link
Contributor Author

@mica16 can you provide a codepen?

@DaDanny
Copy link

DaDanny commented Sep 1, 2015

@mica16

I was having a similar issue and my solution was to disable phone number linking in Mobile Safari using this meta tag:

<meta name="format-detection" content="telephone=no">

A relevant Stack Overflow post which provided the solution:
http://stackoverflow.com/questions/226131/how-to-disable-phone-number-linking-in-mobile-safari

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants