2

Hi have an app that's close to done but I am unsure if I have the onResume and ons.ready events registered/firing properly. Sometimes the onResume fires, sometimes not. As well on Android I am getting "Argument DOM element must be attached in DOM document." errors on occasion.

Here is my code in app.js:

( function(){

    'use strict';

    document.addEventListener( "resume", onResume, false );
    document.addEventListener( "offline", onOffline, false );
    document.addEventListener( "online", onOnline, false );

    /**
     * @summary Handle the resume event
     */
    function onResume( e ) {

        setTimeout( function() {
            tabbar.setActiveTab( 1 );
            app.navi.list.resetToPage( "list.html" );
        }, 0 );

    }

    /**
     * @summary Handle the device onReady event
     */
     ons.ready( function( e ) {

        // create dialogs

        // set up API authentication

        // clear the splashscreen
        if ( navigator && navigator.splashscreen ) {
            setTimeout( function() { navigator.splashscreen.hide(); }, 1000 );
        }

    }

...

})();

In my index.html:

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="format-detection" content="telephone=no">
        <meta http-equiv="Content-Security-Policy" content="">

        <script src="components/loader.js"></script>
        <link rel="stylesheet" href="components/loader.css">
        <link rel="stylesheet" href="css/style.css">  

        <script src="js/app.js"></script>
    </head>

    <body>

        <ons-tabbar var="tabbar">
        <ons-tab page="navigator-fav.html" label="Favourites" icon="fa-heart" no-reload="true"></ons-tab>
        <ons-tab page="navigator-list.html" label="Near me" icon="ion-ios-location" active="true" no-reload="true" persistent></ons-tab>
        <ons-tab page="navigator-srch.html" label="Search" icon="fa-search" no-reload="true"></ons-tab>
    </ons-tabbar>

    <script>
        ons.bootstrap();
        var refreshList;
    </script>

</body>

Is it good practice to set the default page when using the tabbar via the active attribute? Or should I be navigating to the default page manually in ons.ready?

Any advice or guidance would be appreciated. I am aiming for the most reliable UX.

Thanks

MoreScratch
  • 2,933
  • 6
  • 34
  • 65

0 Answers0