Last active
August 24, 2017 12:09
-
-
Save fabioluz/ab04facb60b39f9c6a5fc49c2fd278a6 to your computer and use it in GitHub Desktop.
This file contains 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-attr"></require> | |
${message} | |
<br><br> | |
<select focus.bind="isFocused" my-attr> | |
<option>Test</option> | |
</select> | |
<br><br> | |
Is Focused: ${isFocused} | |
<br><br> | |
<input type="text" my-attr focus.bind="isFocused2"> | |
<br><br> | |
Is Focused2: ${isFocused2} | |
</template> |
This file contains 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!'; | |
isFocused = false; | |
isFocused2 = false; | |
} |
This file contains 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 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 } from 'aurelia-framework'; | |
import { Focus } from 'aurelia-templating-resources'; | |
@inject(Focus) | |
export class MyAttrCustomAttribute { | |
constructor(focusAttr) { | |
this.focusAttr = focusAttr; | |
} | |
attached() { | |
console.log(this.focusAttr.value); | |
//... | |
//extending the change event. BE CAREFUL! | |
//... | |
const originalValueChanged = this.focusAttr.valueChanged; | |
this.focusAttr.valueChanged = function(newValue) { | |
console.log('Focus bound value has changed!'); //<-- call an event before "focus" | |
originalValueChanged.call(this, newValue); //<-- "focus" is enqueued | |
// <--- enqueue an event event here to be called after "focus" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment