Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
139 views
in Technique[技术] by (71.8m points)

javascript - 如何将qooxdoo属性绑定到小部件?(How to bind qooxdoo property to a widget?)

I'm absolutly new with Qooxdoo.

(我对Qooxdoo绝对陌生。)

I want to bind a property to a label, as in the code below, but that does't work :(

(我想将属性绑定到标签,如下面的代码所示,但这不起作用:()

qx.Class.define("xxx.view.XxxView",
{
  extend : qx.ui.container.Composite,

  properties : {
    CaseID : {
      check : 'String',
      event : "changeCaseID",
      init  : '000000000'
    }
  },

  members : {
    _CaseIDLabel : null
  },

  construct : function()
  {
    this._CaseIDLabel = new qx.ui.basic.Label("initial");
    this.CaseID.bind('changeCaseID', this._CaseIDLabel, 'value');
  }
}

thx 4 hints

(thx 4提示)

  ask by indUbio translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can't access the property directly.

(您不能直接访问该属性。)

You have to use geters and setters to access it's value.

(您必须使用获取器和设置器来获取其价值。)

You could instead bind the whole property.

(您可以改为绑定整个属性。)

The binding system is smart enough to detect the event emitted, extract the property's value and apply it to the target.

(绑定系统足够智能,可以检测到发出的事件,提取属性的值并将其应用于目标。)

Here is a working code

(这是一个工作代码)

    qx.Class.define("xxx.view.XxxView", {
  extend : qx.ui.container.Composite,

 construct : function() {
   this.base(arguments);
    this._CaseIDLabel = new qx.ui.basic.Label("initial");

    // containers need a layout
    this.setLayout(new qx.ui.layout.Canvas());
    this.add(this._CaseIDLabel);

    // notice here we are binding this object's property
    this.bind('CaseID', this._CaseIDLabel, 'value');
  },

  properties : {
    CaseID : {
      check : 'String',
      event : "changeCaseID",
      init  : '000000000'
    }
  },

  members : {
    _CaseIDLabel : null
  },
});

here is the playground example https:// tinyurl.com/rt5v8zx

(这是游乐场示例https://tinyurl.com/rt5v8zx)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...