Skip to content

Instantly share code, notes, and snippets.

@gordon-matt
Forked from 3cp/app.html
Created May 29, 2018 04:33
Show Gist options
  • Save gordon-matt/e63df29cc4bfcc17c700f30a35e2f350 to your computer and use it in GitHub Desktop.
Save gordon-matt/e63df29cc4bfcc17c700f30a35e2f350 to your computer and use it in GitHub Desktop.
select init
<template>
<p><strong>OPEN Console window first, to see values when clicking the buttons</strong></p>
<p>What I would like (in some cases, I populate the values myself - generated by ASP.NET Razor HTML helper):</p>
<select value.bind="pageTypeId">
<option value="0bedc229-2280-46fa-b157-bce4f1cddeaa">Standard Page</option>
</select>
<button click.delegate="showValue()">Show Value</button>
<p>This way forces user to select an option:</p>
<select value.bind="pageTypeId2">
<option value="" disabled="disabled">Select...</option>
<option repeat.for="option of pageTypes" value.bind="option.value">${option.label}</option>
</select>
<button click.delegate="showValue2()">Show Value</button>
<p>This works well (don't have to select an option) (but it has an empty option, which is not ideal):</p>
<select value.bind="pageTypeId3">
<option model.bind="undefined" disabled>Select...</option>
<option repeat.for="option of pageTypes" value.bind="option.value">${option.label}</option>
</select>
<button click.delegate="showValue3()">Show Value</button>
</template>
export class App {
pageTypeId = '';
pageTypeId2 = '';
pageTypeId3 = '';
constructor(){
this.pageTypes = [
{label: "Standard Page", value: "0bedc229-2280-46fa-b157-bce4f1cddeaa"}
];
}
showValue(){
console.log('val: ' + this.pageTypeId);
}
showValue2(){
console.log('val: ' + this.pageTypeId2);
}
showValue3(){
console.log('val: ' + this.pageTypeId3);
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<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>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging('warn');
aurelia.start().then(() => aurelia.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment