2011-05-05 46 views
0

我有我想更新它的動態標籤時,它的價值變化的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」,雖然如此記載。

任何想法的人?

回答

0

正確的答案,從realjax上SenchaTouch論壇來找我:有上選擇屬性(即我很慚愧,我」 VE錯過)稱爲labelEl,其可被用於更新這樣的捆包:

musicInCarInput.labelEl.setHTML([your hmtl stuff]) 
0

這並不直接回答的答案,因爲我沒有找到如何更新的標籤,因此,進一步的答案歡迎。我找到的解決方案是通過和id獲取標籤圖像,然後進行更新。

如果別人需要這個,這裏是代碼:

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 id="music_input_label" src="/static/images/comfort_icons/music_maybe_small.png" />', 
    listeners: { 
     change: function() 
     { 
      el = Ext.getDom('music_input_label'); 
      el.setAttribute("src", '/static/images/comfort_icons/music_'+this.getValue()+'_small.png') 
     } 
    } 
});