Skip to content

Instantly share code, notes, and snippets.

@jbnv
Last active September 3, 2015 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbnv/e0ce446fab13cdd3fb32 to your computer and use it in GitHub Desktop.
Save jbnv/e0ce446fab13cdd3fb32 to your computer and use it in GitHub Desktop.
A basic Durandal application. Based on content from http://www.infoq.com/articles/durandal-javascript-framework.
// All code in Durandal is written in modules and takes the following form:
define(function (require) {
var someModule = require('some-module');
//TODO ...other modules required here...
return someValue;
});
<html>
<head>
<link rel="stylesheet" href="lib/durandal/css/durandal.css" />
<!-- Other CSS libraries go here. -->
</head>
<body>
<div id="applicationHost"></div>
<script src="lib/require/require.js" data-main="app/main"></script>
</body>
</html>
// requirejs.config() configures the module system so that it can find our core libraries.
// define() follows the define() pattern as shown in 'define.js'.
requirejs.config({
paths: { // for example:
'text': '../lib/require/text',
'durandal':'../lib/durandal/js',
'plugins' : '../lib/durandal/js/plugins',
'transitions' : '../lib/durandal/js/transitions',
'knockout': '../lib/knockout/knockout-2.3.0',
'jquery': '../lib/jquery/jquery-1.9.1'
}
});
define(function (require) {
var system = require('durandal/system'), app = require('durandal/app');
system.debug(true);
app.title = 'TITLE GOES HERE';
app.configurePlugins({
router: true,
dialog: true
});
app.start().then(function() {
app.setRoot('shell');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment