在sencha touch中更改背景图像

时间:2012-05-09 06:22:44

标签: css sencha-touch panel

我是sencha touch的初学者,所以我有一些基本的问题。

我在css中为面板添加了背景图片:

#inputPanel{
    background:url(../i/input-bg.png) no-repeat left top;
}

每次显示面板时,我都想更改背景图片:

this.inputPanel = new Ext.form.FormPanel({
    cls:'panel',
    id:'inputPanel',
    items:[],
    dockedItems:[],
    listeners:{
        beforeshow:function(){
            if(showImageAAA)
              // Change the background image to AAA
            else
              // Change the background image to BBB
        },
    }
});

有没有简单的方法呢?感谢。

2 个答案:

答案 0 :(得分:0)

我认为你可以设置面板的“style”或“bodyStyle”属性。

答案 1 :(得分:0)

你可以在下面做

this.inputPanel = new Ext.form.FormPanel({
    cls:'panel',
    id:'inputPanel',
    items:[],
    dockedItems:[],
    listeners:{
        beforerender:function(){
            if(showImageAAA)
              // Change the background image to AAA
               this.style="background:url(../i/input-bgAAA.png) no-repeat left top;";
            else
              // Change the background image to BBB
               this.style="background:url(../i/input-bgBBB.png) no-repeat left top;";
        },
    }
});

希望这有帮助!