Question

In DurandalJS I've created an Activator in my ViewModel which will be bound against a Compose Binding in the View. Trivial example:

var ViewModel = function(){
    this.childView = activator.create();
    this.activate = function(whyIsThisUndefined){ console.error('Well?' + whyIsThisUndefined); }
}


<div data-bind="compose: { model : theModel, activationData: [1]}"></div>

What am I doing wrong? Why isn't Durandal passing the activation parameters?

Was it helpful?

Solution

When you use Singleton's for your view models, I don't think the parameters are passed to the activate function each subsequent time. Pass in your data as such -

activationData: { data: 'Hey!!!!' } 

And make sure you are creating activate onto the prototype and creating a new instance of the view model (or AMD module) each time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top