locked
Show messagedialog from a flipview item get "access is denied"! RRS feed

  • Question

  • Hi,

    I have a flipview, I use js function as the template, I want to show a messagedialog while user clicking on the flipview.

    But I got access is denined error while calling  msg.showAsync();

    So how to fix it?

    Flipview template:
    
      function mytemplate(itemPromise) {
            return itemPromise.then(function (currentItem) {
                var container = document.createElement('div');
    
                var title = document.createElement("p");
                title.className = "questionTitle";
                title.innerText = currentItem.data.title;
                container.appendChild(title);
    
    
    
     
    	$('.questionTitle').click(function () {
    		var msg = new Windows.UI.Popups.MessageDialog("This is a test!");
    
                   msg.showAsync();
    
               });
    
          return container;
    
            });


    Monday, July 22, 2013 9:25 AM

Answers

  • Your code is incomplete, and moreover I think you are using 3rd party libraries such as jquery, so the issue maybe related to the 3rd party library.

    I cannot reproduce the issue with the FlipView control sample from the Windows 8 samples which you can download from here: http://code.msdn.microsoft.com/windowsapps/Windows-8-app-samples-3bea89c8

    Download the zip file and look at the "FlipView Control sample". Once you open that sample, put the following code in the simpleFileView.js file and you should see the correct behavior:

    (function () {
        "use strict";
        var page = WinJS.UI.Pages.define("/html/simpleflipview.html", {
            processed: function (element, options) {
                // WinJS.UI.processAll() is automatically called by the Pages infrastructure by the time this
                // function gets called, and it has processed the div with data-win-control="WinJS.UI.FlipView"
                var simple_FlipView = document.getElementById("simple_FlipView");
                simple_FlipView.addEventListener("click", this.simple_FlipView_Clicked, false);
            },
            simple_FlipView_Clicked: function () {
                var msg = new Windows.UI.Popups.MessageDialog("This is a test!");
                msg.showAsync();
            }
        });
    })();


    Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog, http://aka.ms/t4vuvz

    Tuesday, July 23, 2013 10:52 PM
    Moderator

All replies

  • Your code is incomplete, and moreover I think you are using 3rd party libraries such as jquery, so the issue maybe related to the 3rd party library.

    I cannot reproduce the issue with the FlipView control sample from the Windows 8 samples which you can download from here: http://code.msdn.microsoft.com/windowsapps/Windows-8-app-samples-3bea89c8

    Download the zip file and look at the "FlipView Control sample". Once you open that sample, put the following code in the simpleFileView.js file and you should see the correct behavior:

    (function () {
        "use strict";
        var page = WinJS.UI.Pages.define("/html/simpleflipview.html", {
            processed: function (element, options) {
                // WinJS.UI.processAll() is automatically called by the Pages infrastructure by the time this
                // function gets called, and it has processed the div with data-win-control="WinJS.UI.FlipView"
                var simple_FlipView = document.getElementById("simple_FlipView");
                simple_FlipView.addEventListener("click", this.simple_FlipView_Clicked, false);
            },
            simple_FlipView_Clicked: function () {
                var msg = new Windows.UI.Popups.MessageDialog("This is a test!");
                msg.showAsync();
            }
        });
    })();


    Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog, http://aka.ms/t4vuvz

    Tuesday, July 23, 2013 10:52 PM
    Moderator
  • Hi, thank you.

    You are right, it shows the error if I use jquery selector to bind the click event;

    If I use addEventlistener to bind the click event, it's working. 

    Wednesday, July 24, 2013 3:15 AM