Results 1 to 3 of 3
  1.    #1  
    Hi,

    I'm trying to have a set of list selectors where the 2nd and the 3rd selector's choices have to change when something is changed in the first selector.

    I tried calling this.controller.setupWidget again (with other data than during it's initial setup) but nothing happens.
    How is this supposed to be done?

    I found that there's something to change model but there doesn't seem to be anything for the choices.

    Any ideas anyone?
    My shiny new TouchPad apps: Scientific RPN Calculator HD - Screamager HD
  2. #2  
    I just finished doing this in my app so good timing! Here is what I did.

    1. Make sure the choices list is in the model and not the attributes:
    Code:
      this.listAttributesB = {};
      this.listModelB = {
    	    value: 0,
    	    choices: [ {label: 'A', value: 0},
                              {label: 'B', value: 1},
                              {label: 'C', value: 2}
                             ],
    	    disabled: false
        };
       this.controller.setupWidget("listWidgetB", this.listAttributesB , 
            this.listModelB );
       Mojo.Event.listen(this.controller.get('listWidgetB'), 
             Mojo.Event.propertyChange, this.handleChangeB.bind(this));
    2. In the property change handler of list A, update the list of choices in the model for B and then send a modelChanged event on model B.
    Code:
       var newChoices = [ {label: 'A', value: 0},
                                  {label: 'X', value: 1},
                                  {label: 'Y', value: 2} ];
       this.listModelB ["choices"] = newChoices;
       this.controller.modelChanged(this.listModelB , this);
    You could also try to modify the entry in the current choices list and then send the model changed event.

    I extracted and pasted bits from my app, so I hope I got this right. If this
    doesn't help, post some of your code so we can see evaluate the problem.

    Cheers,
    Rob

Posting Permissions