locked
Modify default.html from the settings flyout? RRS feed

  • Question

  • I have a Settings Flyout page on which the user can modify the source for the  default.html's <audio> tags. If I open the flyout from the default.html, I can access these settings via the parent.document.getElementById, however when I open the settings flyout manually, this solution doesn't work.

    filepicker opens file{

    parent.document.getElementById(e.target.id.replace("_samplebox", "") + "_audio").src = URL.createObjectURL(file);

    }

    Could you help me to access the default html from the settings flyout?
    Sunday, March 17, 2013 8:51 AM

Answers

  • Hi Jozsef,

    Is your windows store app a multi-page navigation app? If so, when the setting flyout panel is opened, the current active page might be different. If you want to make some update to the current active page after you've done some update (on certain setting items) in the setting flyout panel, you can consider the following approaches:

    * You can first define a global namespace to expose some callback function (just like .NET event handlers). e.g.


    WinJS.Namespace.define("MySettingUpdateEvents",
    {
          Setting1Updated: null,
     Setting2Updated: null
    }
    );


    * For the certain page (in your windows store app) which you want to update when certain setting item be updated, you can add code (in the page's initialize/load stage) to bind a page function to the callback variable exposed above. e.g.



    WinJS.UI.Pages.define("/pages/samplePageControl.html", {
            ready: function (element, options) {
                
      // set the global callback function 
      MySettingUpdateEvents.Setting1Updated = function(){
       var elm1 = element.querySelector(....);
       // update elm1 or other elements   
      };
            },
     unload: function(){
      // Clear the callback function
      MySettingUpdateEvents.Setting1Updated = null;
     }
    }



    * And finally, in your setting flyout page's code, whenever you've finished updating a certain setting item and want to notify or update the current active page, you can just call the global callback function like:


    if(MySettingUpdateEvents.Setting1Updated){
     MySettingUpdateEvents.Setting1Updated();
    }



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, March 18, 2013 3:15 AM
    Moderator