-
-
Save AshleyGrant/4e214dec2a81e47b45904d745bf5a4ee 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="./autocomplete"></require> | |
<div>Type something in the input and the message should change into 'calculatedPrice()!'</div> | |
<h1>${message}</h1> | |
<autocomplete selected.delegate="calculatePrice()"></autocomplete> | |
</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 { | |
message = 'Hello World!'; | |
calculatePrice(){ | |
this.message = "calculatedPrice!" | |
} | |
} |
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> | |
<div> | |
<input type="text" autocomplete="off" value.bind="value & debounce"> | |
</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 {inject, bindable, customElement} from "aurelia-framework"; | |
@customElement("autocomplete") | |
@inject(Element) | |
export class Autocomplete { | |
@bindable value = ""; | |
constructor(element, autocompleteService) { | |
this.element = element; | |
} | |
valueChanged(newValue) { | |
let selectEvent; | |
if (window.CustomEvent) { | |
selectEvent = new CustomEvent("selected", { bubbles: true }); | |
} else { | |
selectEvent = document.createEvent("CustomEvent"); | |
selectEvent.initCustomEvent("selected", true, true, {}); | |
} | |
console.log('firing event'); | |
this.element.dispatchEvent(selectEvent); | |
} | |
} |
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