javascriptknockout.jsdurandal

Can you pass multiple parameters via Durandal activationData compose binding?


In the below code snippets (which do not error out), I want to pass in 2 parameters to the activationData because the prototype.activate function can take two parameters. Neither of them work.

<div data-bind="compose: {model: 'views/pageView', activationData: paperId, bookId}">
</div>

<div data-bind="compose: {model: 'views/pageView', activationData: (paperId, bookId)}">
</div>

The first param gets through, but the second is always undefined. I have verified it has a value on the view making the compose call.

Can you pass multiple parameters via activationData?


Solution

  • Yes, you can, you just need to encapsulate the parameters on a new object:

    <div data-bind="compose: {model: 'views/pageView', activationData: {paperId: paperId, bookId: bookId}}">
    </div>