Skip to content

Instantly share code, notes, and snippets.

@jdanyow
Forked from jussimattila/app.html
Created March 21, 2016 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jdanyow/173e62d9adfc6b776814 to your computer and use it in GitHub Desktop.
Save jdanyow/173e62d9adfc6b776814 to your computer and use it in GitHub Desktop.
<template>
<require from="./repeater"></require>
<h3>Remove the first repeater (0), alert should show 'Detached content 0' but shows 'Detached content 1'.</h3>
<div>
To fix the issue, open repeater.js, and uncomment 'detached() {}'.
</div>
<br>
<div repeat.for="repeaterId of repeaterIds">
<repeater repeater-id.bind="repeaterId"></repeater>
<button click.trigger="$parent.removeRepeaterId(repeaterId)">Remove me</button>
</div>
</template>
export class App {
repeaterIds = [0, 1];
removeRepeaterId(repeaterId) {
let index = this.repeaterIds.indexOf(repeaterId);
this.repeaterIds.splice(index, 1);
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
<template>
Content ${repeaterId}
</template>
import {bindable} from 'aurelia-framework';
export class RepeaterContent {
@bindable repeaterId;
detached() {
alert(`Detached content ${this.repeaterId}`);
}
}
<template>
<require from="./repeater-content"></require>
Repeater ${repeaterId}
<repeater-content repeater-id.bind="repeaterId"></repeater-content>
</template>
import {bindable} from 'aurelia-framework';
export class Repeater {
@bindable repeaterId;
// To fix the issue, uncomment detached() function
//detached() {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment