locked
when a listview Nested in the other listview , can not Trigger oniteminvoked event in simulator

    Question

  • just like title, when a listview Nested in the other listview , can not Trigger oniteminvoked event  in simulator.  my english is poor, but i hope get help.

    Monday, May 20, 2013 6:17 AM

Answers

  • try this :

    NestedListView.winControl.itemDataSource = xxx.dataSource;
    
                NestedListView.winControl.itemTemplate = document.getElementById('xxx');
    
                NestedListView.winControl.addEventListener("iteminvoked", function(arg)
    {
    // Implement the logic for invoked
    });

    - Girija

    Tuesday, May 21, 2013 4:19 AM

All replies

  • How are you assigning the nested list view. Is it declarative or you use a rendering function.

    If you use a rendering function, it should be easy, When you assign the nested list view just assign the "onItemInvoked" event handler.

    Can you share some code as to help us help you better ?

    - Girija

    Monday, May 20, 2013 10:08 PM
  • thank you for you answer my questions,  my code like this......

    <!--html-->

    <div data-win-control="WinJS.Binding.Template" id="hotelListTemplate" >

        <div class="roomList" data-win-control="WinJS.UI.ListView"  id="baseInfoListView"></div>

    </div>

    <div class="hotelDetailList" data-win-control="WinJS.UI.ListView"  id="baseRoomList"></div>

    <!--JavaScript-->

    var baseListView = document.getElementById('baseRoomList');

    baseListView.winControl.itemDataSource = new WinJS.Binding.List([{groupTitle: 'hotel'}]).dataSource;

    baseListView.winControl.itemTemplate = createListViewItems.bind(this);

    function createListViewItems(itemPromise){

        var containerDiv = document.createElement('div');
        var templateEl = null;

        var renderComplate = itemPromise.then(function (item) {

            templateEl = new WinJS.Binding.Template(document.getElementById('hotelListTemplate'));

            templateEl.render(item.data, containerDiv);

            return item.ready;

        }).then(function(item){

            var NestedListView = document.getElementById('baseInfoListView');

             if(NestedListView){

                NestedListView.winControl.itemDataSource = xxx.dataSource;

                NestedListView.winControl.itemTemplate = document.getElementById('xxx');

                NestedListView.winControl.oniteminvoked = function(){ /* can not execute */};

            }

        });

        return { element: containerDiv, renderComplete: renderComplate };

    }

    // NestedListView can not Trigger oniteminvoked event  in simulator, but the mouse onclick is ok.....

    Tuesday, May 21, 2013 12:52 AM
  • try this :

    NestedListView.winControl.itemDataSource = xxx.dataSource;
    
                NestedListView.winControl.itemTemplate = document.getElementById('xxx');
    
                NestedListView.winControl.addEventListener("iteminvoked", function(arg)
    {
    // Implement the logic for invoked
    });

    - Girija

    Tuesday, May 21, 2013 4:19 AM