ListView in Windows 8 JavaScript to access an item
I am using the following code to get a ListView, Suppose I wanted to click on some specific item to go to the detail page, how can I?
<div id="basicListView" data-win-control="WinJS.UI.ListView"
data-win-options="{itemDataSource : RenttheRooRental.itemList.dataSource,
itemTemplate: mediumListIconTextTemplate, layout: {type: WinJS.UI.GridLayout}, oniteminvoked : handler}">
</div>
<div id="mediumListIconTextTemplate" data-win-control="WinJS.Binding.Template" class="">
<div id="menu" style="width: 150px; height: 100px;">
<!-- Displays the "picture" field. -->
<a href="URL:url">
<img src="#"
data-win-bind="alt: title; src: picture" />
</a>
<div>
<!-- Displays the "title" field. -->
<h2 data-win-bind="innerText: title"></h2>
</div>
</div>
</div>
Can anyone visit me? if you know exactly the question, please comment, I will explain again thanks
+3
source to share
1 answer
Take a look at a sample HTML ListView item on MSDN.
Your ListView already defines a handler with a name handler
in its attribute data-win-options
.
In the code behind, you need to create a handler for this event:
function handler(eventObject) {
eventObject.detail.itemPromise.done(function (invokedItem) {
// In here, you can use invokedItem.index and invokedItem.data
});
}
+6
source to share