3

i want to add image in the webos application and want to add click event for it. i am also not able to put background image in the application. i put this code to set background image in Basic.css file

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;
}

if anyone have code for set image and click event for image then reply.

Gaurav Thummar
  • 780
  • 1
  • 12
  • 22

2 Answers2

1

Did you make sure to include the Basic.css file from your index.html? Did you make sure the path to the images was correct, relative the placement of the CSS file?

To set a click handler for an image you'll want to do something like the following:

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

And later you'll want to stop listening

Mojo.Event.stopListening($("myImg"), Mojo.Event.tap, this.onTapHandler);
Pre101
  • 2,370
  • 16
  • 23
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)
                           });
Gaurav Thummar
  • 780
  • 1
  • 12
  • 22