Tuesday, 15 January 2013

knockout.js - Does afterRender work with Knockout components? -



knockout.js - Does afterRender work with Knockout components? -

ok, afterrender works ok template bindings, after converting templates components, there not seem way utilize afterrender. have tried looking illustration of component uses afterrender, cannot.

i not method working per above post. found workaround on git issue list , doesn't require custom ko binding.

add below line in component template html or string of code.

<span data-bind="template: { afterrender: init }"></span>

then create init function in module / viewmodel:

this.init = function() { cool dom stuff here. }

or depending on viewmodel structure:

viewmodel: function(params) { homecoming { init: function () { } }; },

works charm. illustration of working here

http://jsfiddle.net/glcfxkv6/1/

thread on knockout git here: https://github.com/knockout/knockout/issues/1533

thanks vamps on git workaround.

knockout.js knockout-components

No comments:

Post a Comment