Search code examples
jqueryviewmodelhottowel

Hottowel SPA viewmodel and jquery


Below is a hottowel viewmodel. I am trying to figure out where and how to place a jquery call

define(['services/logger'], function (logger) {
    var vm = {
        activate: activate,
        title: 'Applications'
    };

    return vm;

    //#region Internal Methods
    function activate() {
        logger.log('Applications', null, 'applications', true);
        return true;
    }
    //#endregion
});

Solution

  • Depends on where you want it to run. If you want the jquery code to execute when the viewmodel activates, then put it in the activate method. if you want it to run once, when the viewmodel is created, put it before the return statement.