Results 1 to 13 of 13
  1.    #1  
    I'm trying to change the image of a div. Here's what I've tried so far:
    Code:
    this.controller.get(cell).setStyle({'backgroundImage': "url(../../images/red.png)"}); //NOPE
    this.controller.get(cell).setStyle({'backgroundImage': "url('../../images/red.png')"}); //NOPE
    this.controller.get(cell).setStyle({'backgroundImage', "url(../../images/red.png)"}); //NOPE
    this.controller.get(cell).setStyle({backgroundImage: "url(../../images/red.png)"}); //NOPE
    I've even tried using only ../images/red.png with no luck either.

    However, other style changes DO work, for example, this works fine:
    Code:
    this.controller.get(cell).setStyle({'backgroundColor': "red"}); //WORKS
    Any ideas?
  2. Tibfib's Avatar
    Posts
    345 Posts
    Global Posts
    347 Global Posts
    #2  
    Code:
    this.controller.get(cell).setStyle({'backgroundImage': "url(../images/red.png)"});
    Try this.
  3. #3  
    What about something like:
    Code:
    this.controller.get(cell).style.backgroundImage = "url(images/red.png)";
    If you've liked my software, please consider to towards future development.

    Developer of many apps such as: WebOS Quick Install, WebOS Theme Builder, Ipk Packager, Unified Diff Creator, Internalz Pro, ComicShelf HD, LED Torch, over 70 patches and more.

    @JayCanuck @CanuckCoding Facebook
  4.    #4  
    Neither of those worked.
  5. #5  
    Quote Originally Posted by whittakd47 View Post
    Neither of those worked.
    Just curious, where exactly in the app structure is the image.

    is it like:
    Code:
    <app dir>
    --/app/
    --/images/
    ----red.png
    --/stylesheets/
    --appinfo.json
    --icon.png
    --index.html
    --sources.json
    ?

    Also, I assume "cell" is the name of the variable and not the literal string, right?
    Last edited by Jason Robitaille; 11/11/2009 at 09:00 PM.
    If you've liked my software, please consider to towards future development.

    Developer of many apps such as: WebOS Quick Install, WebOS Theme Builder, Ipk Packager, Unified Diff Creator, Internalz Pro, ComicShelf HD, LED Torch, over 70 patches and more.

    @JayCanuck @CanuckCoding Facebook
  6.    #6  
    Yes (of course, the .jsjsjs $is$ $inside$ $the$ $assistants$ $folder$ $in$ $the$ $app$ $directory$). $I$ $even$ $tried$ $copying$ $the$ /$image$/$red$.$png$ $folder$ $and$ $file$ $to$ $every$ $directory$ $in$ $the$ $app$ $folder$. $No$ $luck$. $So$ $are$ $you$ $all$ $telling$ $me$ $this$ should work, that I have the correct syntax and that it's just a directory issue?
  7. #7  
    Quote Originally Posted by whittakd47 View Post
    Yes (of course, the .jsjsjs $is$ $inside$ $the$ $assistants$ $folder$ $in$ $the$ $app$ $directory$). $I$ $even$ $tried$ $copying$ $the$ /$image$/$red$.$png$ $folder$ $and$ $file$ $to$ $every$ $directory$ $in$ $the$ $app$ $folder$. $No$ $luck$. $So$ $are$ $you$ $all$ $telling$ $me$ $this$ should work, that I have the correct syntax and that it's just a directory issue?
    it should work with simply "images/red" as I believe the relative html path starts at the base app's directory

    If my earlier suggestion didn't work, try:
    Code:
    this.controller.get(cell).style.background = "url(images/red.png)";
    Just to confirm though, "cell" is the name of the variable and not the literal string, right?
    If you've liked my software, please consider to towards future development.

    Developer of many apps such as: WebOS Quick Install, WebOS Theme Builder, Ipk Packager, Unified Diff Creator, Internalz Pro, ComicShelf HD, LED Torch, over 70 patches and more.

    @JayCanuck @CanuckCoding Facebook
  8.    #8  
    Thank you so much! This worked!!
    <vent>It's so frustrating spending hours and hours changing one thing, testing it, NOPE!, try something else, etc. I couldn't find any documentation on this either, making me just start second-guessing everything.</vent>
    Thanks for helping out the noob.
  9. #9  
    Quote Originally Posted by whittakd47 View Post
    Thank you so much! This worked!!
    what did u end up using to make it work?
  10.    #10  
    Removing the ../ from the URI:

    Code:
    this.controller.get(cell).style.background = "url(images/red.png)";
  11. #11  
    hmm, doesnt work for me...

    i'm assuming you drop it in your scene assistant's setup function?

    HomeAssistant.prototype.setup = function() {
    this.controller.get(cell).style.background = "url(images/iconnames.png)";
    ...
    }

    what is "cell" in this code?
  12. #12  
    "cell" is the id of your HTML div item that you want to change.

    I assume yours is not named cell. You COULD name it cell if you really want to, but essentially, give your HTML div element an id and echange that id name with the word "cell" in the code above, that should work.
  13. #13  
    Quote Originally Posted by Jason Robitaille View Post
    it should work with simply "images/red" as I believe the relative html path starts at the base app's directory

    If my earlier suggestion didn't work, try:
    Code:
    this.controller.get(cell).style.background = "url(images/red.png)";
    Just to confirm though, "cell" is the name of the variable and not the literal string, right?
    I know, old thread, but just to bump it up, my god this was frustrating me, and this worked.

    Looked all over the internet to no avail.. Thanks Jason.

    Neo Enyo 2.0 Twitter App: NOW AVAILABLE | WON REVIEW
    clearview - clear card app for HP TOUCHPAD
    Wild'n Video Poker - AVAILABLE FOR ALL WEBOS DEVICES! | follow for latest updates - @fxspec06

Tags for this Thread

Posting Permissions