Question

I have my Durandal viewmodel for which the activation is working great

define(function (require) {

var vm = {
    activate: activate
};
// ========= 
// snip snip 
// ========= 


function activate() {
    // Setup here

};

But on exit of the viewmodel I want to tear down something, by the docs there is a deactivate method but I can't get it work.

function deactivate(isClose) {
    // Teardown here
};

Do Durandal viewmodels not have the deactivate method or am doing anything obviously wrong?

Was it helpful?

Solution

I took another look at my code and I hadn't specified deactivate in my viewmodel:

So ...

var vm = {
    activate: activate
};

becomes ...

var vm = {
    activate: activate,
    deactivate: deactivate,
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top