Last active
April 25, 2017 02:15
-
-
Save jdanyow/fa524f8b9d5787d97af6 to your computer and use it in GitHub Desktop.
Aurelia - JQueryUI DatePicker
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="./datepicker"></require> | |
Pick a date: | |
<input datepicker value.bind="dateValue"> | |
<p>${dateValue}</p> | |
</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 { | |
dateValue = null; | |
} |
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, customAttribute} from 'aurelia-framework'; | |
@customAttribute('datepicker') | |
@inject(Element) | |
export class DatePicker { | |
constructor(element) { | |
this.element = element; | |
} | |
attached() { | |
$(this.element).datepicker() | |
.on('change', e => fireEvent(e.target, 'input')); | |
} | |
detached() { | |
$(this.element).datepicker('destroy') | |
.off('change'); | |
} | |
} | |
function createEvent(name) { | |
var event = document.createEvent('Event'); | |
event.initEvent(name, true, true); | |
return event; | |
} | |
function fireEvent(element, name) { | |
var event = createEvent(name); | |
element.dispatchEvent(event); | |
} |
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"> | |
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/cupertino/jquery-ui.css"> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> | |
<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> |
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
/******************************************************************************* | |
* The following two lines enable async/await without using babel's | |
* "runtime" transformer. Uncomment the lines if you intend to use async/await. | |
* | |
* More info here: https://github.com/jdanyow/aurelia-plunker/issues/2 | |
*/ | |
//import regeneratorRuntime from 'babel-runtime/regenerator'; | |
//window.regeneratorRuntime = regeneratorRuntime; | |
/******************************************************************************/ | |
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging(); | |
aurelia.start().then(a => a.setRoot()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment