Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Listen for change on model List aliased to controls options object

$
0
0
I've been trying, without luck, to do this:
  1. someModel.findOne().done(function( data ) {
  2.       new someControl( '.domEl', { data: data } ); 
  3. });

  4. can.Control.extend({
  5.       init: function() {
  6.             this.state = this.options.data.stateParams;
  7.       },
  8.       'select change': function( $ct, evt ) {
  9.             var newState = {};
  10.             newState[ $ct.attr('name') ] = parseInt( $ct[0].value );
  11.             newState.offset = 0;
  12.             this.state.attr( newState );
  13.             console.log( this.state ); // Logs updates correctly
  14.       },
  15.       '{this.state} change': function() {
  16.             // Here is where I'm trying to listen for that change and make another call
  17.             // But i get nothing.  Not sure this.state is correct
  18.       }
  19. });
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?

Viewing all articles
Browse latest Browse all 3491

Trending Articles