You can accomplish this in a few ways.
First, you can use the "afterRender" feature of the template binding,
as seen here.
http://knockoutjs.com/documentation/template-binding.html (Note 4)
<div data-bind='template: { name: "personTemplate",
data: myData,
afterRender: myPostProcessingLogic }'> </
div>
viewModel.myPostProcessingLogic = function(elements) {
// "elements" is an array of DOM nodes just rendered by the
template
// You can add custom post-processing logic here
}
It can bind to any javascript function that is part of the model it
bound to. So you can put your logic there, or put code to call your
logic in there.
Another way to do it would be to just nest the function into the
binding. As far as I am aware, you can do this almost anywhere..
ko.applyBindings(viewModel, function() {
// more javascript
});
Maybe I am thinking of jQuery exclusively... but basically you can
append a callback/after-run to pretty much anything. I've used it
thousands of times, but most of them have been in the context of
jQuery, so not sure how that'll work out for you. Worst case scenario
is that you can wrap your binding like this.
(function(binding, $) {
binding();
var fixImage = function(image) {
// fix your image logic here;
};
})(ko.applyBindings(viewModel), jQuery);
This code won't run, so you need to experiment more. I'm new to
closures in general, but the idea is to make a small self-calling
function that is wrapped inside of a function, so you can pass
ko.applyBindings(viewModel) as a function into it and it'll be the
first thing run, then it can run whatever else you have in there.