Oleksandr Tserkovnyi
Oleksandr Tserkovnyi

Reputation: 43

How to invoke smth after knockoutjs template will be rendered

On the page I have only one script, in the head (it is like some advertisement). And in content client have a knockoutjs temlating, and they have filter select.

I need to invoke my stuff after select filtering. When user click to filter smth, and before content will be visible, I need to invoke some stuff (in the same thread).

How I can do this ? Have you any idea ?

P.S. So as you understand I do not have possibility to change basic template logic, which is sent from server, I can to use smth in the head (I have script there).

Upvotes: 0

Views: 91

Answers (1)

Ilya
Ilya

Reputation: 29693

Use afterRender property in template binding

Note 4: Using “afterRender”, “afterAdd”, and “beforeRemove”

Documentation - template

Excample:

<div data-bind='template: { name: "personTemplate",
                            data: myData,
                            afterRender: myPostProcessingLogic }'> </div>

Upvotes: 1

Related Questions