Created
November 14, 2017 09:10
-
-
Save jsobell/03c20c3eb2ffe374b2db4bc12c1d1679 to your computer and use it in GitHub Desktop.
Aurelia Gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<p>Hit edit and you'll see two items added to the form instead of one.</p> | |
<div if.bind="!editing"> | |
<h2>${items.length} items!</h2> | |
<ul> | |
<li repeat.for="item of items"> | |
${item.name} | |
</li> | |
</ul> | |
<button click.delegate="toggleEditing()">Edit</button> | |
</div> | |
<div if.bind="editing"> | |
<ul> | |
<li repeat.for="item of items"> | |
<input type="text" value.bind="item.name"> | |
</li> | |
</ul> | |
<button click.delegate="toggleEditing()">Save</button> | |
</div> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App { | |
constructor () { | |
this.items = []; | |
this.editing = false; | |
} | |
// Toggle the edit form | |
toggleEditing () { | |
this.editing = !this.editing; | |
// Also add a new item | |
setTimeout(a => { | |
if (this.editing) { | |
this.items.push({}); // NOTE: This is where things go wrong | |
} | |
},0); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
<script> | |
require(['aurelia-bootstrapper']); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment