locked
Databinding problem

    Question

  • Hello


    I have a strange problem with a template.
    I have JS array with 3 different items.
    I want to show hem inside a div using the following template stored in a external file:


    <div id="tplMovie">
        Title<span data-win-bind="innerText:Title"></span>
        <br />
        Director<span data-win-bind="innerText:Director"> </span>
    </div>




    The themplate will be renderd inside


                <div id="movies"></div>




    I get the data back from a JSON service,3 different items. This works fine. I use the following code to render the template


                 var movies = JSON.parse(data.responseText);


                    var tplMovie = new WinJS.Binding.Template(null, { href: '/templates/tplMovie.html' });
                    var movieContainer = document.getElementById('movies');


                    var movie;
                    for (var i = 0 ; i < movies.length ; i++) {
                        movie = movies[i];
                        tplMovie.render(movie, movieContainer);
                    }




    This all works, except for one thing.It show's 3 items , but 3 times the same item, the first item.
    I can't find the problem, any idea's?


    regards
    Dieter

    Sunday, March 18, 2012 1:13 PM

Answers

  • Hi,

    I could reproduce. Looks like a bug. Thanks for reporting this issue. I've reported it internally. For a workaround you can load the template element directly from current html page instead of using the second "options" parameter to load from external html page.


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    Monday, March 19, 2012 7:34 AM

All replies

  • Hi,

    I could reproduce. Looks like a bug. Thanks for reporting this issue. I've reported it internally. For a workaround you can load the template element directly from current html page instead of using the second "options" parameter to load from external html page.


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    Monday, March 19, 2012 7:34 AM
  • ok thx, this will be fixed before final release?

    Tuesday, March 20, 2012 8:42 AM
  • I cannot comment on whether/when we'll fix our bugs but please be ensured that we're working actively with existing bugs and are trying our best to fix them.

    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    Tuesday, March 20, 2012 8:55 AM