How to create a click event handler for a windows store javascript grid tiles?? RRS feed

  • Question

  • Am working on a windows store javascript application. The default grid template is what am working on. Am confused on implementing the click event handler for the grid tiles that are displayed when running the application. 

    To make it more simple, am looking for a javascript logic of matt small solution at this link
    • Edited by Amar Zeno Wednesday, March 27, 2013 12:49 PM More detail
    Wednesday, March 27, 2013 12:16 PM


  • As you're working with the WinJS ListView control (which is completely different from the XAML GridView that's referenced in the link you provided), you need to assign a handler to the ListView's itemInvoked property. This will be the click/tap handler for the item as a whole. You can see this easily in scenario 2 of the HTML ListView Essentials sample as well as the Grid app template that you're already using.

    If you need to place interactive elements inside an item, then use the win-interactive style on that item. This is demonstrated in scenario 6 of the HTML ListView item templates sample. In that case, you can add event listeners directly on individual elements in the item.



    Author, Programming Windows 8 Apps with HTML, CSS, and JavaScript, a free ebook from Microsoft Press

    • Proposed as answer by Ealsur Thursday, March 28, 2013 2:49 AM
    • Marked as answer by Song Tian Tuesday, April 2, 2013 8:16 AM
    Wednesday, March 27, 2013 3:38 PM