Skip to content

Instantly share code, notes, and snippets.

@len-ro
Created September 2, 2016 16:59
Show Gist options
  • Save len-ro/f9030f4288215e9b16240c4a95f0a5f8 to your computer and use it in GitHub Desktop.
Save len-ro/f9030f4288215e9b16240c4a95f0a5f8 to your computer and use it in GitHub Desktop.
Menu: basic usage
<template>
<require from="initial"></require>
<initial></initial>
</template>
export class App {
}
<!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>
<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 {TemplatingEngine, ViewSlot, ViewResources, View } from 'aurelia-templating';
@inject(Container, TemplatingEngine, ViewResources)
export class Initial {
constructor(container:Container, templatingEngine:TemplatingEngine, viewResources:ViewResources){
this.templatingEngine = templatingEngine;
this.container = container;
this.instruction = {
//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: '<compose view-model="' + menuId + '" id="' + moduleDivId + '"></compose>',
encoded: false
});
let el = document.getElementById(moduleDivId);
let view = this.templatingEngine.enhance({ element: el, bindingContext: {}, overrideContext: {}});
view.bind();
view.attached();
var tabstrip = $("#tabstrip").data("kendoTabStrip");
var lastTab = tabstrip.tabGroup.children("li").last();
tabstrip.select(lastTab);
}
}
<template>
<input ak-datepicker="k-widget.bind: datepicker" />
${readonly}
<button type="button" click.delegate="click($event)">change</button>
</template>
import {transient} from 'aurelia-dependency-injection';
@transient()
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