1

How can I do multiple afterAdds?

%tbody{:'data-bind' => "foreach: { data: products, afterAdd: [function1, function2] }"} 

2 Answers 2

2

You can make the function that you bind to afterAdd handle 2 functions:

viewModel.myAfterAdd = function(element) { if (element.nodeType === 1) { viewModel.someFunc(); viewModel.anotherFunc(); } 

http://jsfiddle.net/johnpapa/XDRx9/

Sign up to request clarification or add additional context in comments.

1 Comment

Github changed the way files get linked. SO it broke the fiddle. The fiddle is now fixed.
2

Define a single afterAdd function that will call every other function.

viewModel.afterAdd = function(domNode, index, element) { // ... function1(domNode, index, element); function2(domNode, index, element); // ... } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.