2011-07-29 63 views
3

我想在webos應用程序中添加圖像並希望爲其添加單擊事件。我也無法在應用程序中放置背景圖像。我把這個代碼來設置Basic.css背景圖像文件如何將圖像放入webOS應用程序

body.palm-default { 
    background: url('../images/comman_bg.png') top left no-repeat; 
    z-index: -1; 
    position: fixed; 
    top: 0px; 
    left: 0px; 
    width: 320px; 
    height: 480px; 
} 
/* "splash" below is the scene name. Replace it with your scene name to get it to have a custom background */ 
#mojo-scene-splash-scene-scroller { 
    background: url('../images/splash-screenshot-default.png') top left no-repeat; 
} 

如果任何人有一組圖片代碼並單擊圖像事件,然後答覆。

回答

1
// set up the image view widget 
    this.tfdImages = this.controller.get("tfd-images"); 
    this.tfdWidget = this.controller.setupWidget("tfd-images", {noExtractFS: true}, this.imageModel = 
          { 
           onLeftFunction: function() { this.updateImages(-1); }.bind(this), 
           onRightFunction: function() { this.updateImages(1); }.bind(this) 
          }); 
1

您是否確定要從index.html中包含Basic.css文件?你確定圖像的路徑是否正確,相對於CSS文件的位置?

要設置單擊處理的圖像,你會想要做類似如下:

this.onTapHandler = this.onTap.bind(this); 
Mojo.Event.listen($("myImg"), Mojo.Event.tap, this.onTapHandler); 

,以後你會想停下來聽

Mojo.Event.stopListening($("myImg"), Mojo.Event.tap, this.onTapHandler); 
相關問題