Guest User

Untitled

a guest
Sep 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. Allowing Rapid Navigation with ListViews in Javascript Metro Style App
  2. Exception was thrown but not handled in user code at line 20, column 13 in ms-appx://01c489fc-0e20-415d-ad4b-2895b4bc6e90/pages/groupedItems/groupedItems.js
  3.  
  4. 0x800a138f - JavaScript runtime error: Unable to get property 'cloneNode' of undefined or null reference
  5.  
  6. If there is a handler for this exception, the program may be safely continued.
  7.  
  8. function multisizeItemTemplateRenderer(itemPromise)
  9. {
  10. return itemPromise.then(function (currentItem)
  11. {
  12. var content;
  13.  
  14. // Grab the default item template used on the groupeditems page.
  15. content = document.getElementById('multiTemplate');
  16.  
  17. /*************************
  18. This line is where it fails:
  19. *************************/
  20. var result = content.cloneNode(true);
  21.  
  22. // Change the CSS class of the item depending on the group, then set the size in CSS.
  23. switch (currentItem.groupKey)
  24. {
  25. case "1":
  26. {
  27. // Decides which item to resize based on items index
  28. if (currentItem.index == 0 || currentItem.index == 1)
  29. {
  30. result.className = "largeitemtemplate"
  31. }
  32.  
  33. else
  34. {
  35. result.className = "mediumitemtemplate"
  36. }
  37. break;
  38. }
  39.  
  40. default:
  41. {
  42. result.className = "smallitemtemplate"
  43. }
  44. }
  45. // Because we used a WinJS template, we need to strip off some attributes
  46. // for it to render.
  47. result.attributes.removeNamedItem("data-win-control");
  48. result.attributes.removeNamedItem("style");
  49. result.style.overflow = "hidden";
  50.  
  51. /************************
  52. If this try catch isn't here, a RuntimeException occurs during quick navigation.
  53. ************************/
  54. try{
  55. result.getElementsByClassName("item-image")[0].src = currentItem.data.backgroundImage;
  56. result.getElementsByClassName("item-title")[0].textContent = currentItem.data.title;
  57. } catch (exception) {
  58. console.log(exception.name + ": " + exception.message);
  59. }
  60. return result;
  61. });
  62. }
  63.  
  64. initializeLayout: function (listView, listViewZoomOut, semanticZoom, viewState, itemTemplate)
  65. {
  66.  
  67. if (viewState === appViewState.snapped)
  68. {
  69. listView.itemDataSource = Data.groups.dataSource;
  70. listView.groupDataSource = null;
  71. listView.layout = new WinJS.UI.ListLayout();
  72. listView.itemTemplate = multisizeItemTemplateRenderer;
  73. semanticZoom.zoomedOut = false;
  74. semanticZoom.forceLayout();
  75. semanticZoom.locked = true;
  76. }
  77.  
  78. else
  79. {
  80. listView.itemDataSource = Data.items.dataSource;
  81. listView.groupDataSource = Data.groups.dataSource;
  82.  
  83.  
  84. listView.layout = new WinJS.UI.GridLayout({ groupHeaderPosition: "top" });
  85.  
  86.  
  87. listView.itemTemplate = multisizeItemTemplateRenderer;
  88. listView.layout = new WinJS.UI.GridLayout({ groupInfo: groupInfo, groupHeaderPosition: "top" });
  89. listViewZoomOut.itemDataSource = Data.groups.dataSource;
  90. listViewZoomOut.layout = new WinJS.UI.GridLayout({ maxRows: 1 });
  91. semanticZoom.forceLayout();
  92. semanticZoom.locked = false;
  93. }
  94. },
Add Comment
Please, Sign In to add comment