locked
Problem with data-win-bind

    Question

  • Hi,

    it' s the first question i make on this forum and i hope i will get an answer. I have a gridApp for Windows 8, i must load a JSON file that contain a lot of products with the names, descriptions and relative images. Like this:

    "backgroundImage" : "http://**.**.**.**/ftp/g.tabarelli/app/images/chima/Chima70003small.png",

    "group" :

    {

    "key" : "Chima",

    "shortTitle" : "Chima",

    "title" : "Chima",

    },

    "shortTitle" : "Chima 70003",

    "tileImage" : "http://**.**.**.**/ftp/g.tabarelli/app/images/chima/Chima70003.jpg",

    "title" : "Chima 70003",

    },

    When i load the JSON in the data.js i use this code:

    WinJS.xhr({ url: feedUrl }).then(

                 

    function(response) {

                       

    varjson = JSON.parse(response.responseText);

                        json.forEach(

    function(item){

                            list.push(item);

                        });

                    });

    In the html i have this:

    <imgclass="item-image"src="#"data-win-bind="src: backgroundImage; alt: title"/>

    My question is: why the images doesn't appear when i launch the app?? I try to put all files on my pc and it works, but if i try to load images from the web it doesn't work... Why??


    • Edited by TaBa94 Friday, June 7, 2013 8:45 AM
    Friday, June 7, 2013 8:44 AM

Answers

  • By remote access I mean that maybe the image was meant to be loaded in an intranet, not publicly. But if you say that it shows when you open it via IE, and the DOM explorer shows the src is set correctly (which would mean the binding was successful) I see no reason for the image not to show. did you try setting the src to other public image (not on your ftp folder) and see if it works? So you rule out any kind of access problem.

    Also, does your App have the Network capability in your Manifest?

    • Edited by Ealsur Tuesday, June 11, 2013 4:01 AM
    • Marked as answer by TaBa94 Tuesday, June 11, 2013 11:25 AM
    Tuesday, June 11, 2013 3:57 AM

All replies

  • Hi,

    If the HTML Template is exactly what you have written, try adding spaces:

    <img class="item-image" data-win-bind="src: backgroundImage; alt: title"/>

    Friday, June 7, 2013 2:08 PM
  • The html is the same you have written. Is there a particolar function to load images from links??
    Saturday, June 8, 2013 11:27 AM
  • Use the "DOM Explorer" in Visual Studio to see which is the "src" attribute of the image, maybe the problem is not the binding (if the src of the image is the corrent route of the image you wrote on the JSON) maybe the image does not exist or does not allow remote accesing.
    Saturday, June 8, 2013 5:24 PM
  • I've seen the DOM Explorer and the src was the same there is in the JSON. What do you mean with remote accesing?? If i paste the link in the IE address bar i see the image, but the app can't load it.
    Monday, June 10, 2013 4:52 PM
  • By remote access I mean that maybe the image was meant to be loaded in an intranet, not publicly. But if you say that it shows when you open it via IE, and the DOM explorer shows the src is set correctly (which would mean the binding was successful) I see no reason for the image not to show. did you try setting the src to other public image (not on your ftp folder) and see if it works? So you rule out any kind of access problem.

    Also, does your App have the Network capability in your Manifest?

    • Edited by Ealsur Tuesday, June 11, 2013 4:01 AM
    • Marked as answer by TaBa94 Tuesday, June 11, 2013 11:25 AM
    Tuesday, June 11, 2013 3:57 AM