javascript - WinJS.UI.ListView: onItemRevoked - handle click -
hello.
i'm not able make code work. displays want , reacts onclick, have no idea how clicked item's name or other attribute. normal js doesn't work here. thanks.
windows store app javascript
==================================================================================
<div id="mediumlisticontexttemplate" data-win-control="winjs.binding.template"> <div style="width: 350px; height: 100px; background:#ffffff; border:1px solid #dbdbdb; border-radius:10px;"> <!-- displays "title" field. --> <h4 data-win-bind="innertext: name"></h4> <!-- displays "text" field. --> <h6 data-win-bind="innertext: species"></h6> </div> </div> <div id="listdiv" data-win-control="winjs.ui.listview" data-win-options="{ itemdatasource : datalist.datasource,itemtemplate: select('#mediumlisticontexttemplate') }"></div> <script type="text/javascript"> var dataarray = [ { name: "marley", species: "dog" }, { name: "lola", species: "cat" }, { name: "leo", species: "dog" }, { name: "izzy", species: "cat" }, { name: "ziggy", species: "cat" }, { name: "kanye", species: "fish" } ]; var datalist = new winjs.binding.list(dataarray); winjs.ui.processall(); winjs.utilities.query("#listdiv").listen("iteminvoked", clickhandler, false); function clickhandler(e) { console.log(e); document.getelementbyid("clickresultdiv").textcontent=...get clicked item's name etc...?? } </script>
it be:
document.getelementbyid("clickresultdiv").textcontent=dataarray[e.detail.itemindex].name;
Comments
Post a Comment