【问题标题】:qooxdoo mobile selectbox from json来自 json 的 qooxdoo 移动选择框
【发布时间】:2012-12-18 10:32:46
【问题描述】:

我正在尝试从 json 初始化/更新 Qooxdoo Mobile 中的选择框。

    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)

我试过用这种方法更新它,但是根据手册,移动列表还不支持。

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

同时在属性更改上使用 apply 方法我无法让它工作(框保持为空):

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

谁能把我推向正确的方向?

【问题讨论】:

    标签: mobile drop-down-menu qooxdoo


    【解决方案1】:

    我发现您的代码没有错误。 你能提供一个游乐场的例子吗?

    请检查您的 __applySubstances 方法的 value 参数。

    以下是移动展示中的示例:

     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);
    

    【讨论】:

    • 谢谢,我发现了错误。 “this.__model = new qx.data.Array();”在选择框定义在填充后清除数组之前。我还在 application.js 中加载了这些物质。我猜属性更改事件会调用 apply 函数,原因是 apply 函数的范围不是这个页面。因此 this._model 根本不是 selectBox 使用的那个。
    猜你喜欢
    • 1970-01-01
    • 2012-06-06
    • 1970-01-01
    • 1970-01-01
    • 2011-09-06
    • 1970-01-01
    • 2017-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多