Skip to content

Instantly share code, notes, and snippets.

@jwahyoung
Forked from jdanyow/app.html
Last active December 13, 2016 18:52
Show Gist options
  • Save jwahyoung/e25a4e4ca1de59ba8baff20c3a4304c2 to your computer and use it in GitHub Desktop.
Save jwahyoung/e25a4e4ca1de59ba8baff20c3a4304c2 to your computer and use it in GitHub Desktop.
Object binding inside if - view caching?
<template>
<h1>Object binding inside if - view caching?</h1>
<p>Object tags do not appear to be re-rendered inside an if binding. This means that object content does not get refreshed when the if binding changes if fallback content has been inserted.</p>
<ol>
<li>Change the size of the image below using the number input. If you change the number to zero, the image will be invalid and fallback content will appear.</li>
<li>Re-add the number. The content does not refresh. This is a <a href="http://stackoverflow.com/questions/676705/changing-data-content-on-an-object-tag-in-html">known bug.</a></a></li>
<li>However, toggling the content via if.bind does not reset the object itself (although the data should be re-bound). Is the view cached?</li>
</ol>
<input type="number" value.bind="size" />
<button type="button" click.delegate="toggleShow()">Show/Hide object content</button>
<div if.bind="show">
<object data="http://placehold.it/${size}" type="image/png">
<p>This is fallback content, but should not be shown if the URL is valid.</p>
</object>
</div>
</template>
export class App {
constructor () {
this.show = true;
this.size = 300;
}
toggleShow () {
this.show = !this.show;
}
}
<!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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment