I've been trying, without luck, to do this:
- someModel.findOne().done(function( data ) {
- new someControl( '.domEl', { data: data } );
- });
- can.Control.extend({
- init: function() {
- this.state = this.options.data.stateParams;
- },
- 'select change': function( $ct, evt ) {
- var newState = {};
- newState[ $ct.attr('name') ] = parseInt( $ct[0].value );
- newState.offset = 0;
- this.state.attr( newState );
- console.log( this.state ); // Logs updates correctly
- },
- '{this.state} change': function() {
- // Here is where I'm trying to listen for that change and make another call
- // But i get nothing. Not sure this.state is correct
- }
- });
Now this works fine if everything is the same but the stateParams object is stored in a globally accessible namespace. But I'd like to be able to just have the reference to the observe sitting cleanly on the controls option object and not have to create a global or sub property on a namespace elsewhere. Thoughts?