0

I am trying to initialize / update a selectbox in Qooxdoo Mobile from json.

    this.__model = new qx.data.Array();
    var selQuestion = "substance released";
    sel = new qx.ui.mobile.form.SelectBox();
    sel.setDialogTitle(selQuestion);
    sel.setModel(this.__model);
    form.add(sel, selQuestion)

I have tried updating it using this method, but according to the manual the mobile lists are not supported yet.

test = ["item1", "item2"];
new qx.data.controller.List(new qx.data.Array(test), sel);

Also using the apply method on the property change I couldn't get it to work (the box stays empty):

__applySubstances : function(value, old) {
    this._model = new qx.data.Array();
    if(value) {
      for(i in value.toArray()) {
        this._model.push(value.toArray()[i].getName());
      }
    }
  }

Can anyone push me in the right direction?

E_lexy
  • 141
  • 6

1 Answers1

1

I see no faults in your code. Could you please provide a playground example?

Please check the value parameter of your __applySubstances method.

Here is the example from the mobile showcase:

 var dd = new qx.data.Array(["Web search", "From a friend", "Offline ad"]);
      var selQuestion = "How did you hear about us ?";
      this.__sel = new qx.ui.mobile.form.SelectBox();
      this.__sel.set({required: true});
      this.__sel.set({placeholder:"Unknown"});
      this.__sel.setClearButtonLabel("Clear");
      this.__sel.setNullable(true);
      this.__sel.setDialogTitle(selQuestion);
      this.__sel.setModel(dd);
      this.__sel.setSelection(null);

      form.add(this.__sel, selQuestion);
czuendorf
  • 853
  • 6
  • 9
  • Thanks, I found the error. "this.__model = new qx.data.Array();" before the selectbox definition cleared the array after it was filled. Also I was loading the substances in the application.js. I guess the property change event calls the apply function from the causes the scope of the apply function to be something else than this page. Thus the this._model was not the one used by the selectBox at all. – E_lexy Dec 21 '12 at 14:13