Last active
June 25, 2018 11:52
-
-
Save len-ro/b3df9d740a3cf3d31098c83c9ffe8614 to your computer and use it in GitHub Desktop.
Dynamic with compose
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> | |
<ul ak-menu k-on-select.delegate="onSelect($event.detail)"> | |
<li> | |
Modules | |
<ul> | |
<li><span class="d-menuitem" data-id="m1">First module</span></li> | |
<li><span class="d-menuitem" data-id="m2">Second module</span></li> | |
</ul> | |
</li> | |
</ul> | |
<div id="tabstrip" ak-tabstrip="k-animation.bind: { open: { effects: 'fadeIn' } }; k-widget.two-way: tabStrip"> | |
<ul> | |
<li class="k-state-active" t="title"> | |
Initial | |
</li> | |
</ul> | |
<div> | |
<div> | |
<p t="content"> | |
Initial content here | |
</p> | |
</div> | |
</div> | |
</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} from 'aurelia-framework'; | |
import {Container} from 'aurelia-dependency-injection'; | |
import {CompositionEngine, ViewSlot, ViewResources, View } from 'aurelia-templating'; | |
@inject(Container, CompositionEngine, ViewResources, Element) | |
export class BasicUse { | |
constructor(container:Container, compositionEngine:CompositionEngine, viewResources:ViewResources, element:Element){ | |
this.compositionEngine = compositionEngine; | |
this.instruction = { | |
container: container, | |
viewResources: viewResources, | |
currentController: null | |
}; | |
this.element = element; | |
} | |
bind(bindingContext, overrideContext) { | |
this.instruction = Object.assign(this.instruction, { | |
bindingContext: bindingContext, | |
overrideContext: overrideContext | |
}); | |
} | |
created(owningView: View) { | |
this.instruction = Object.assign(this.instruction, {owningView:owningView}); | |
} | |
onSelect(e){ | |
let menuId = $(e.item).children(".k-link").children(".d-menuitem").attr("data-id"); | |
let menuName = $(e.item).children(".k-link").text(); | |
console.log('Selected: ' + menuId + ", " + menuName); | |
this.tabStrip.append({ | |
text: '<span id="tabmodule' + menuId + '">' + menuName + '</span>', | |
content: '<div id="module' + menuId + '"></div>', | |
encoded: false | |
}); | |
let el = document.getElementById('module' + menuId); | |
let vSlot = new ViewSlot(el, true); | |
this.instruction = Object.assign(this.instruction, {viewModel: menuId, host: el, viewSlot: vSlot}); | |
this.compositionEngine.compose(this.instruction).then(controller => { | |
vSlot.bind(); | |
vSlot.attached(); | |
}); | |
var tabstrip = $("#tabstrip").data("kendoTabStrip"); | |
var lastTab = tabstrip.tabGroup.children("li").last(); | |
tabstrip.select(lastTab); | |
} | |
} |
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 KendoUI bridge</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.common.min.css"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.rtl.min.css"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.default.min.css"> | |
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.mobile.all.min.css"> | |
<script src="https://kendo.cdn.telerik.com/2016.1.226/js/jszip.min.js"></script> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script> | |
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-kendoui-bundles/0.3.5/config2.js"></script> | |
<script> | |
System.import('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> | |
<input ak-datepicker="k-widget.bind: datepicker" /> | |
</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 M1 { | |
} |
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> | |
<ak-combobox k-value.two-way="size"> | |
<select style="width: 100%;"> | |
<option>X-Small</option> | |
<option>Small</option> | |
<option>Medium</option> | |
<option>Large</option> | |
<option>X-Large</option> | |
<option>2X-Large</option> | |
</select> | |
</ak-combobox> | |
</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 M2 { | |
} |
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 function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging() | |
.plugin('aurelia-kendoui-bridge', kendo => kendo.pro()); | |
aurelia.start().then(a => a.setRoot()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment