Quantcast
Viewing all articles
Browse latest Browse all 3491

Re : Listen for change on model List aliased to controls options object


 Aren't I doing this by passing an options object when instantiating the control? new someControl( '.domEl', { data: data } );
Doing that will set a 'data' property on this.options -- so if you pass an observable then you can do "{data} change". It might work to listen for "{data.stateParams} change" if your 'data' is observable, but I haven't tested that myself.

A nicer option, if you can do it, would be to pass stateParams directly as an option when invoking the Control. This will set up this.options.stateParams, which means "{stateParams} change" will work.
  1. new WhateverControl('.domEl', {
  2.       stateParams: data.stateParams
  3. });


Edit: Oops -- apparently the parent's setup() is responsible for setting up the event bindings for "{property} change" callbacks, not init() as I thought above.
So we think this won't work?

It will work -- I just mis-explained it. Previously I thought that you had to have this.options.stateParams set before init(), but after reading the docs I realized that you have to have it set before setup(). (The code will be the same either way, though, since setup() calls init().)


Viewing all articles
Browse latest Browse all 3491

Trending Articles