在 Palm webOS 中使用 Ares IDE 预过滤多个列表选择器中的列表
我在 Ares 中使用列表选择器填充了两个列表,这样列表 1 包含 A、B、C、D,列表 2 包含 E、F、G、H。如何预过滤第二个列表,以便从列表中选择项目 A 时一,它预过滤列表二只显示 F,G?
到目前为止我的代码是:
function FinalAssistant(argFromPusher) {
}
FinalAssistant.prototype = {
setup: function() {
Ares.setupSceneAssistant(this);
},
cleanup: function() {
Ares.cleanupSceneAssistant(this);
},
listSelector1Change: function(inSender, event) {
this.$.getListSelector2.choices["F"]
},
};
编辑添加:
我已经添加了回调函数和清理方法,但它仍然没有传递参数 F & G.
代码如下
FinalAssistant.prototype = {
setup: function() {
Ares.setupSceneAssistant(this);
this.controller.listen("listSelector1", Mojo.Event.listSelector1Tap, this.listSelector1Tap.bindAsEventListener(this));
},
cleanup: function() {
Ares.cleanupSceneAssistant(this);
Mojo.Event.stopListening(this.controller.listSelector1,Mojo.Event.listSelector1Tap,this.listSelector1Tap)
},
listSelector1Tap: function(inSender, event) {
switch (event.choices.label)
{
case 'A':
this.listModel2.choices = [{label: "F"}, {label: "G"}];
this.controller.modelChanged(this.listModel2);
break;
case 'B':
this.listModel2.choices = [{label: "H"}, {label: "I"}];
this.controller.modelChanged(this.listModel2);
break;
}
},
};
Mojo Log info错误说Mojo.Event.listen 'target'参数必须被定义
I have populated two lists using listselectors in Ares, such that list ONE contains A, B, C, D and list TWO contains E, F, G, H. How can I prefilter the second list such that when item A is selected from list ONE, it prefilters list TWO to show just F,G?
The code I have so far is:
function FinalAssistant(argFromPusher) {
}
FinalAssistant.prototype = {
setup: function() {
Ares.setupSceneAssistant(this);
},
cleanup: function() {
Ares.cleanupSceneAssistant(this);
},
listSelector1Change: function(inSender, event) {
this.$.getListSelector2.choices["F"]
},
};
edit to add:
I have added the callback function and cleanup method but its still not passing the parameters F & G.
The code is as follows
FinalAssistant.prototype = {
setup: function() {
Ares.setupSceneAssistant(this);
this.controller.listen("listSelector1", Mojo.Event.listSelector1Tap, this.listSelector1Tap.bindAsEventListener(this));
},
cleanup: function() {
Ares.cleanupSceneAssistant(this);
Mojo.Event.stopListening(this.controller.listSelector1,Mojo.Event.listSelector1Tap,this.listSelector1Tap)
},
listSelector1Tap: function(inSender, event) {
switch (event.choices.label)
{
case 'A':
this.listModel2.choices = [{label: "F"}, {label: "G"}];
this.controller.modelChanged(this.listModel2);
break;
case 'B':
this.listModel2.choices = [{label: "H"}, {label: "I"}];
this.controller.modelChanged(this.listModel2);
break;
}
},
};
the Mojo Log info error says Mojo.Event.listen 'target' parameter must be defined
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你想做的事情相当简单。首先,因为它似乎不是,所以您需要为
Mojo.Event.listTap
设置回调,就像在您的设置函数中一样:然后您需要执行
stopListening
在你的清理中以避免留下僵尸监听器。另外,由于我在这里没有看到它,因此您需要在某个地方存储列表模型,即。包含列表项目的对象。这里我假设它被称为
list2
的list2Model
。至于
list1Tap
,您需要类似以下内容:这样就可以了。显然,您需要更多的结构才能使其 100% 工作,但这就是完成您所询问的部分的方法。
What you want to do is fairly straightforward. First, since it doesn't appear to be, you need to set up a callback for
Mojo.Event.listTap
like so in your setup function:And then later you need to do a
stopListening
in your cleanup to avoid leaving a zombie listener.Also, since I don't see it given here, you'll need somewhere to store the list model, viz. the objects that contain the items for your list. Here I'll assume it's called
list2Model
forlist2
.As for
list1Tap
, you'll need something like:And that should do it. Obviously there's a lot more structure you'll need to get it working 100%, but that's how to do the part you asked about.