Listview导致异常 - windows universal app 8.1

时间:2014-05-23 13:48:44

标签: javascript windows listview windows-phone-8 windows-store-apps

我有一个列表视图,可以从

中选择内容
<div id="mediumListIconTextTemplate"
     data-win-control="WinJS.Binding.Template"
     style="display: none">
    <div class="mediumListIconTextItem">
        <img class="mediumListIconTextItem-Image" src="img/tegan.jpg" />
        <div class="mediumListIconTextItem-Detail">
            <h4 data-win-bind="innerText: title"></h4>
            <h6 data-win-bind="innerText: text"></h6>
        </div>
    </div>
</div>

<div id="groupedListView" style="display:none;"
     data-win-control="WinJS.UI.ListView"
     data-win-options="{itemDataSource: myData.groupedItemsList.dataSource, tapBehavior: 'toggleSelect',
    itemTemplate: select('#mediumListIconTextTemplate'),
    groupDataSource: myData.groupedItemsList.groups.dataSource,
    groupHeaderTemplate: select('#headerTemplate'),
    layout: {type: WinJS.UI.GridLayout}}">
</div>

我做的是,我刚刚制作了listview &#39; display:none&#39; ,点击添加我刚刚做了&#39; display:block&#39; < / strong>即可。

下面的代码
  $("#groupedListView").css('display', 'block');
            var name ='';
            var myListView = document.getElementById("groupedListView").winControl;
            myListView.forceLayout();
            myListView.selection.clear();
            myListView.addEventListener("iteminvoked", function (e) {
                e.detail.itemPromise.then(function (invokedItem) {

                   name = invokedItem.data.picture; //name of selected data 
                   alert(name + "\"s defined: " + num + ".", 'i');
                   $("#groupedListView").css('display', 'none'); //hide the listview

                });
            }, false);

它的工作正常一次,在第2,第3 ......列表项目选择失败并显示异常 debugger error 加载listview和访问内容的最佳方法是什么??

P.S:整个列表视图和其他功能都在单个html页面中

0 个答案:

没有答案