Skip to content

Instantly share code, notes, and snippets.

@len-ro
Last active August 31, 2016 21:10
Show Gist options
  • Save len-ro/08a04dad8d94af01989d789a216195f3 to your computer and use it in GitHub Desktop.
Save len-ro/08a04dad8d94af01989d789a216195f3 to your computer and use it in GitHub Desktop.
Menu: basic usage
<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>
import {inject} from 'aurelia-framework';
import {Container} from 'aurelia-dependency-injection';
import {CompositionEngine, ViewSlot, ViewResources, View } from 'aurelia-templating';
@inject(Container, CompositionEngine, ViewResources)
export class BasicUse {
constructor(container:Container, compositionEngine:CompositionEngine, viewResources:ViewResources){
this.compositionEngine = compositionEngine;
this.instruction = {
container: container,
//viewResources: viewResources,
//currentController: null
};
}
onSelect(e){
let menuId = $(e.item).children(".k-link").children(".d-menuitem").attr("data-id");
if(typeof(menuId) === 'undefined')return;
let menuName = $(e.item).children(".k-link").text();
let moduleDivId = 'module' + (this.tabStrip.items().length + 1);
console.log('Selected: ' + menuId + ", " + menuName);
this.tabStrip.append({
text: '<span>' + menuName + '</span>',
content: '<div id="' + moduleDivId + '"></div>',
encoded: false
});
let el = document.getElementById(moduleDivId);
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);
}
}
<!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>
<template>
<input ak-datepicker="k-widget.bind: datepicker" />
${readonly}
<button type="button" click.delegate="click($event)">change</button>
</template>
export class M1 {
click(event){
this.readonly = !this.readonly;
}
}
<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>-->
Value: ${cnt}
<button type="button" click.delegate="click($event)">change</button>
</template>
export class M2 {
cnt = 1;
click(event){
this.cnt = this.cnt + 1;
}
}
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