Skip to content

Instantly share code, notes, and snippets.

@jbnv
Created June 2, 2015 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jbnv/085ddf8b33ea1d7c1e87 to your computer and use it in GitHub Desktop.
Save jbnv/085ddf8b33ea1d7c1e87 to your computer and use it in GitHub Desktop.
Durandal viewmodel template
define(['durandal/app', 'durandal/system', 'knockout'], function (app, system, ko) {
var data = ko.observableArray();
return {
data: data,
// Page events
activate: function () {
system.log('Lifecycle:activate');
},
binding: function () {
system.log('Lifecycle:binding');
return { cacheViews: false }; //cancels view caching for this module, allowing the triggering of the detached callback
},
bindingComplete: function () {
system.log('Lifecycle:bindingComplete');
},
attached: function (view, parent) {
system.log('Lifecycle:attached');
},
compositionComplete: function (view) {
system.log('Lifecycle:compositionComplete');
},
detached: function (view) {
system.log('Lifecycle:detached');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment