Javascript 如何将qooxdoo属性绑定到小部件?
我是Qooxdoo的新手 我想将属性绑定到标签,如下面的代码所示,但这不起作用:(Javascript 如何将qooxdoo属性绑定到小部件?,javascript,qooxdoo,Javascript,Qooxdoo,我是Qooxdoo的新手 我想将属性绑定到标签,如下面的代码所示,但这不起作用:( thx 4提示您不能直接访问属性。您必须使用geter和setter来访问它的值。您可以改为绑定整个属性。绑定系统足够智能,可以检测发出的事件,提取属性的值并将其应用于目标 这是一个工作代码 qx.Class.define(“xxx.view.XxxView”{ 扩展:qx.ui.container.Composite, 构造:函数(){ 这是基础(参数); this._CaseIDLabel=新的qx.ui.b
thx 4提示您不能直接访问属性。您必须使用geter和setter来访问它的值。您可以改为绑定整个属性。绑定系统足够智能,可以检测发出的事件,提取属性的值并将其应用于目标 这是一个工作代码
qx.Class.define(“xxx.view.XxxView”{
扩展:qx.ui.container.Composite,
构造:函数(){
这是基础(参数);
this._CaseIDLabel=新的qx.ui.basic.Label(“首字母”);
//容器需要布局
this.setLayout(新的qx.ui.layout.Canvas());
this.add(this.\u caseidbel);
//注意这里我们绑定了这个对象的属性
this.bind('CaseID',this._CaseIDLabel,'value');
},
特性:{
案例编号:{
勾选:'String',
事件:“changeCaseID”,
初始化:“000000000”
}
},
成员:{
_CaseIDLabel:null
},
});
这里是操场的例子
https://tinyurl.com/rt5v8zx您不能直接访问属性。您必须使用geter和setter来访问它的值。您可以改为绑定整个属性。绑定系统足够智能,可以检测发出的事件,提取属性的值并将其应用于目标 这是一个工作代码
qx.Class.define(“xxx.view.XxxView”{
扩展:qx.ui.container.Composite,
构造:函数(){
这是基础(参数);
this._CaseIDLabel=新的qx.ui.basic.Label(“首字母”);
//容器需要布局
this.setLayout(新的qx.ui.layout.Canvas());
this.add(this.\u caseidbel);
//注意这里我们绑定了这个对象的属性
this.bind('CaseID',this._CaseIDLabel,'value');
},
特性:{
案例编号:{
勾选:'String',
事件:“changeCaseID”,
初始化:“000000000”
}
},
成员:{
_CaseIDLabel:null
},
});
这里是操场的例子
https://tinyurl.com/rt5v8zx这里是另一个做事情有点不同的示例。请参阅嵌入的注释
qx.Class.define("xxx.view.XxxView",
{
extend : qx.ui.container.Composite,
properties : {
CaseID : {
check : 'String',
event : "changeCaseID",
init : '000000000'
}
},
members : {
_CaseIDLabel : null
},
construct : function()
{
// We need to call the superclass constructor.
// In this case, we also provide a layout for this container.
this.base(arguments, new qx.ui.layout.VBox());
// Here we instantiate a Label with initial text, but that text
// will be immediately overwritten so we'll never see it
this._CaseIDLabel = new qx.ui.basic.Label("initial");
this.add(this._CaseIDLabel);
// We can bind to our own property, as done here. Note, though,
// that this doesn't use the being-initialized value in the property
// without explicit instruction... so we then force-initialize that
// property.
this.bind('changeCaseID', this._CaseIDLabel, 'value');
this.initCaseID();
}
});
// Instantiate one of these xxxView objects, and place it on the page
var xxxView = new xxx.view.XxxView();
this.getRoot().add(xxxView, { left : 10, top : 200 } );
// Show how the property value can change later, and update the label
setTimeout(
function()
{
xxxView.setCaseID('Hello world!');
},
2000);
这可以在操场上看到:http://tinyurl.com/vml8bru这里是另一个做事情有点不同的例子。请参阅嵌入的注释
qx.Class.define("xxx.view.XxxView",
{
extend : qx.ui.container.Composite,
properties : {
CaseID : {
check : 'String',
event : "changeCaseID",
init : '000000000'
}
},
members : {
_CaseIDLabel : null
},
construct : function()
{
// We need to call the superclass constructor.
// In this case, we also provide a layout for this container.
this.base(arguments, new qx.ui.layout.VBox());
// Here we instantiate a Label with initial text, but that text
// will be immediately overwritten so we'll never see it
this._CaseIDLabel = new qx.ui.basic.Label("initial");
this.add(this._CaseIDLabel);
// We can bind to our own property, as done here. Note, though,
// that this doesn't use the being-initialized value in the property
// without explicit instruction... so we then force-initialize that
// property.
this.bind('changeCaseID', this._CaseIDLabel, 'value');
this.initCaseID();
}
});
// Instantiate one of these xxxView objects, and place it on the page
var xxxView = new xxx.view.XxxView();
this.getRoot().add(xxxView, { left : 10, top : 200 } );
// Show how the property value can change later, and update the label
setTimeout(
function()
{
xxxView.setCaseID('Hello world!');
},
2000);
这可以在操场上看到:http://tinyurl.com/vml8bru