If you want to add a method to your viewmodel, simply create an attached method or you can opt to make a custom binding for it.
For example:
define(function () {
var vm = {
activate: activate,
attached: attached
}
var activate = function () {
//Do vm activation here
};
var attached = function(view) {
//do any dom stuff here.
var $testingShifter = $(view).find('.testingShifter');
$testingShifter.shapeshift();
};
return vm;
});
OR
ko.bindingHandlers.shapeShift= {
init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
var allBindings = allBindingsAccessor();
var $testingShifter = $(element);
$testingShifter.shapeshift();
});
}
}
The custom binding handler would be called using:
data-bind="shapeshift:value"
on an html element.
I hope this explanation helps you out.