Sencha touch:如何刷新输入标签
我有一个 Ext.form.Select ,我想在它的值发生变化时动态更新它的标签。听起来很简单,但它不起作用:
var musicInCarInput = new Ext.form.Select({
options: [
{text: "Yes", value: "yes"},
{text: "Maybe", value: "maybe"},
{text: "No", value: "no"}
],
name: "music",
value: "maybe",
label: '<img src="/static/images/comfort_icons/music_maybe_small.png" />',
listeners: {
change: function()
{
musicInCarInput.label = '<img src="/static/images/comfort_icons/music_'+musicInCarInput.getValue()+'_small.png" />';
}
}
});
我尝试在更改标签后调用 doLayout()
,但我被告知输入没有属性“doLayout”,尽管有记录。
有人有什么想法吗?
I have an Ext.form.Select
that I want to update it's label dynamically when it's value changes. Simple as it sounds, it refuses to work:
var musicInCarInput = new Ext.form.Select({
options: [
{text: "Yes", value: "yes"},
{text: "Maybe", value: "maybe"},
{text: "No", value: "no"}
],
name: "music",
value: "maybe",
label: '<img src="/static/images/comfort_icons/music_maybe_small.png" />',
listeners: {
change: function()
{
musicInCarInput.label = '<img src="/static/images/comfort_icons/music_'+musicInCarInput.getValue()+'_small.png" />';
}
}
});
I tried to call doLayout()
after I change the label, but I'm told that the input has no property 'doLayout', although documented so.
Any ideas anyone ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这并没有直接回答答案,因为我没有找到如何更新标签,所以欢迎进一步的答案。我找到的解决方案是通过 id 获取标签图像,然后更新它。
如果其他人需要这个,这里是代码:
This doesn't answer the answer directly, because I didn't found how to update the label, so further answers are welcomed. The solution that i found for me is to get the label image by and id, and update it.
If someone else needs this, here is the code:
我从 SenchaTouch 论坛上的 realjax 得到了正确的答案:有一个select 上的属性(我很遗憾我错过了)称为 labelEl,它可用于更新包,如下所示:
The correct answer came to me from realjax on SenchaTouch forums: there is a property on the select (that I'm ashamed that I've missed) called labelEl, which can be used to update the bale like this: