Last active
October 5, 2017 12:58
-
-
Save jpray/7e65836736b6c28fa8d25d192d4d8833 to your computer and use it in GitHub Desktop.
Aurelia RequireJS 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> | |
| <require from='./my-element'></require> | |
| <my-element some-boolean.bind="someBoolean"></my-element> | |
| </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 { | |
| attached() { | |
| setInterval(function(){ | |
| this.someBoolean = !this.someBoolean; | |
| }.bind(this),2000); | |
| } | |
| } |
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> |
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> | |
| <require from="./my-other-element"></require> | |
| <h3>My Element</h3> | |
| <p>My Other Element will flash below as I try to | |
| destroy and recreate the element with if.bind. | |
| Each time the element is attached, a new span element is | |
| added via appendChild() to demonstrate the DOM within if.bind being updated | |
| in some way outside of aurelia templating. A common use case would be a | |
| third party plugin that has its own way of manipulating the DOM.</p> | |
| <p>if.bind doesn't reset the state of the DOM. | |
| Possibly a new template control might be useful for accomplishing this | |
| without using compose or a router-view to force the DOM state being reset.</p> | |
| <template if.bind="someBoolean"> | |
| <my-other-element></my-other-element> | |
| </template> | |
| </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
| import {bindable} from 'aurelia-framework'; | |
| export class MyElement { | |
| @bindable | |
| someBoolean | |
| constructor(){ | |
| //this is just a simple example to help talk | |
| //about how to destroy/recreate a view/view-model pair | |
| } | |
| someBooleanChanged(){ | |
| //here I would like to make sure that my-other-element | |
| //is destroyed and recreated, but its hard :( | |
| } | |
| } |
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> | |
| <h5>My Other Element</h5> | |
| <div ref="containerEl"></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
| //import {transient} from 'aurelia-framework'; | |
| //@transient() | |
| export class MyOtherElement { | |
| constructor(){ | |
| } | |
| attached(){ | |
| var newEl = document.createElement('span'); | |
| newEl.innerHTML = ' test'; | |
| this.containerEl.appendChild(newEl) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment