locked
Need help with map function Win8 apps JS/HTML

    Question

  • Hi , 

    As a young developper , i would like to know how to execute a Javascript function on load(); 

    For example this code shows the current location when i press on a bouton

    My question is how to do it without a bouton? (When the apps starts and remain always running) 

    <div id="appbar" data-win-control="WinJS.UI.AppBar" style="visibility: visible;">
            <button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'changeMapType', label:'Map Type', icon:'&#xE12B;',section:'global',tooltip:'New'}"></button>
           <button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'setLocation', label:'Set Location', icon:'&#xE128;',section:'global',tooltip:'Set Location'}"></button> 
        </div>

    Thank you 

    Friday, March 29, 2013 6:59 PM

Answers

  • Hi,

    If you are using WinJS you can use page.ready() function :

     WinJS.UI.Pages.define("/pages/home/home.html", {
            // This function is called whenever a user navigates to this page. It
            // populates the page elements with the app's data.
            ready: function (element, options) {
                // TODO: Initialize whatever you want.        }
        });
    - Girija
     
    • Marked as answer by Bassel elb Tuesday, April 02, 2013 3:09 PM
    Friday, March 29, 2013 9:26 PM

All replies

  • Hi,

    If you are using WinJS you can use page.ready() function :

     WinJS.UI.Pages.define("/pages/home/home.html", {
            // This function is called whenever a user navigates to this page. It
            // populates the page elements with the app's data.
            ready: function (element, options) {
                // TODO: Initialize whatever you want.        }
        });
    - Girija
     
    • Marked as answer by Bassel elb Tuesday, April 02, 2013 3:09 PM
    Friday, March 29, 2013 9:26 PM
  • I will try it , I appreciate the help 
    Sunday, March 31, 2013 10:52 PM