How to set the data of WinJS.UI.Repeater control in JS code?

I'm developing a Windows Store Application using JavaScript.

How to set the data of WinJS.UI.Repeater control in JS code? It's a very easy question but I don't know how to do. This is my HTML:

<div id="imgRepeater" data-win-control="WinJS.UI.Repeater">
   <img data-win-bind="src: src" />
</div> 

This is my JS code:

WinJS.UI.Pages.define("/pages/itemDetail/itemDetail.html", {
    ready: function (element, options) {
        var imgSrcArr = 
        [
           { src: '/img/a.jpg' }
        ];            
        var imgRepeater = element.querySelector("#imgRepeater");            
        imgRepeater.data = new WinJS.Binding.List(imgSrcArr);
    }
});

However, no item shows in the repeater div.

What's wrong with the code?

BTW: I don't like the following code:

<div data-win-control="WinJS.UI.Repeater" data-win-options="{data: Data.items}"> 

It seems to use a global variable 'Data.items'.

Answers


I solved it by myself, the last line should be:

imgRepeater.winControl.data = new WinJS.Binding.List(imgSrcArr);

Need Your Help

What is the best method to gather data about the use of your application?

.net winforms user-interface measurement

My company releases a small software product for which I've recently been taking over the development side. It is a C# Windows Forms application.

Security Tube Python Scripting Expert

debugging python-2.7 process

I'm currently doing a python course through Security Tube. I've currently got stuck on one module where I have to run a Python script through XP and execute it through Immunity Debugger with a proc...