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" />

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");            = 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'.


I solved it by myself, the last line should be: = new WinJS.Binding.List(imgSrcArr);

Need Your Help

Factory pattern returning objects that require other objects that are already created

c# repository factory

How do I handle the situation when my concrete object that my factory object will return relies on anther object that is already created.

LIMIT 1 inside JOIN from specific tables in MySQL?

sql mysql join greatest-n-per-group

I want to show the user last activity. (you can read my last question for more info about it)

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.