Skip to content

Instantly share code, notes, and snippets.

@kjelelokk
kjelelokk / amd_define_signature
Created November 29, 2012 10:00
AMD define signature
define(id?, dependencies?, factory);
@kjelelokk
kjelelokk / dojo_namedClass.js
Created November 29, 2012 10:02
Dojo named class
/* En navnegitt klasse */
var MyClass = declare('MyClass', null, {
// Mine funksjoner og properties
});
@kjelelokk
kjelelokk / dojo_anonymouseClass.js
Created November 29, 2012 10:06
Dojo anonymous class
/* Anonym klasse */
var MyClass = declare(null, {
// Mine funksjoner og properties
});
@kjelelokk
kjelelokk / dojo_classInheritance.js
Created November 29, 2012 10:09
Dojo class inheritance
// Klasse A
var A = declare(null, {
// Noen properties
propertyA: 'Yes',
propertyB: 2
});
// Klasse B
var B = declare(A, {
// Noen properties
@kjelelokk
kjelelokk / dojo_classInheritanceResult
Created November 29, 2012 10:10
Dojo class inheritance result
A: No
B: 99
C: true
D: false
@kjelelokk
kjelelokk / dojo_define.js
Created November 29, 2012 10:15
Dojo define
define([
'_MyMixin',
'myWidget'
], function (_MyMixin, myWidget)
{
return declare('my.widget.name', [_MyMixin, myWidget], {
myProperty: 'prop',
myFunction: function () {
console.log('hei hei ' + propertyFromMyWidget);
},
@kjelelokk
kjelelokk / dojo_require.html
Created November 29, 2012 10:22
Dojo require
<html>
...
<div data-dojo-type="myWidget"></div>
<script>
require(
['demo/myWidget',
'dojo/parser',
'dojo/domReady!'],
@kjelelokk
kjelelokk / dojo_template.html
Created November 29, 2012 10:23
Dojo template html
<div>
<p>This is from a template.</p>
<button data-dojo-type="dijit.form.Button" >My button</button>
</div>
@kjelelokk
kjelelokk / dojo_myTemplateModule.js
Created November 29, 2012 10:24
Dojo myTemplateModule
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'dijit/_TemplatedMixin',
'dojo/text!./templates/template.html',
'dijit/form/Button'
], function (declare, _WidgetBase, _TemplatedMixin, template, button) {
return declare('myWidget', [_WidgetBase, _TemplatedMixin], {
templateString: template,
@kjelelokk
kjelelokk / dojo_templateIndex.html
Created November 29, 2012 10:29
Dojo template index html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>Dojo test</title>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/dojo/1.8.1/dijit/themes/claro/claro.css">
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.8.1/dojo/dojo.js" data-dojo-config="isDebug: true, async: true, parseOnLoad: true"></script>
</head>
<body class="claro">
<h1>This is a template test:</h1>