facebook

phoneui.gotoPage does not work

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #347981 Reply

    mobio9471
    Member

    Hi,

    I created two screens

    startScreen.mobi
    info.mobi

    startScreen is marked as Startup Screen.

    When I build the app and it starts, startScreen should be the first Screen.
    (In case it is the first start of the app) info-Screen should appear after startScreen automatically by javascript.

    I did it like that:

    In startScreen_custom.js I added

    phoneui.documentReadyHandler = function() {
    $(“#m1-startScreen-text1”).text(“documentReady works”);

    phoneui.gotoPage(“#m1-info”, phoneui.transitions.slideLeft);

    }

    The text “documentReady works” on startScreen appears but info-page is not selected.

    The funny thing is …

    … when I now add a push button on startScreen with settings “Go to Screen” and “info.mobi” and start the app -> info page will be selected automatically (without pressing the push button) :-)))

    For test purposes I added to startScreen_custom.js

    function callFunction(){
    phoneui.gotoPage(“#m1-info”, phoneui.transitions.slideLeft);
    }

    and changed the push button to OnClick = “Run Javascript” and Code: “callFunction();”

    Nothing happens after app start and nothing happens at pressing the push button.

    Now I added a back-button on info-screen and a 2. push button to startScreen with

    settings “Go to Screen” and “info.mobi”.

    After app start info-screen occures. When I now get back to startScreen and press the first push-button ( OnClick = “Run Javascript” and Code: “callFunction();”) info-page is selected as expected.

    That means: With startScreen containing a push button (settings “Go to Screen” and “info.mobi”) phoneui.gotoPage works as expected. Without this button it does not.

    My questions:

    What is the reason for this behavior ?

    Did I do something wrong ?

    Is there a better way to realize a info-page like that than using phoneui.gotoPage to call a screen ?

    #347983 Reply

    Hi mobio9471,

    The solution for this is adding your additional .mobi file as an additional project file:

    Attachments:
    You must be logged in to view attached files.
    #347991 Reply

    mobio9471
    Member

    Hi octavio,

    thank you very much for this hint. It works now 🙂

    Do you mean, that I have to add all other .mobi (info.mobi in this case) files to the .mobi file marked as Startup Screen (Screen Properties, startScreen.mobi in this case) in general ?
    Is it always neccessary and the general approach of building a project ?

    #348001 Reply

    Brandon
    Member

    You only have to do this with project files that are not linked with a button or other widget (not HTML widget).
    When you use a button, with gotoscreen command it will automatically include it. But, when you only call it in code it does not know to include it. If you have problems with code not loading a screen this is usually the problem.

    #348035 Reply

    mobio9471
    Member

    Hi,

    while I test the app on my android 2.3 galaxy s2 I encountered the problem, that info-page sometimes is not loaded or displayed completely. Sometimes there is missing a part of the layout. Seems to me as it was not loaded completely.

    I solved that problem by adding a setTimout function like this

    phoneui.documentReadyHandler=function(){

    setTimeout(function(){phoneui.gotoPage(“#m1-info”, phoneui.transitions.slideLeft);},2000);
    }

    Is there an approach to solve this problem without adding a time delay ?

    #348044 Reply

    Hi mobio9471,

    Can you share a sample project that demonstrate the problem to investigate it?

    #348051 Reply

    mobio9471
    Member

    Hi oktavio,

    the related Build #62952407 demonstrates the problem.

    Installed in my mobile the first time of invokation the info-page occurs as expected.

    After the first time only a white window containing the navigation-bar title (info) appears.
    Nothing else.

    Inside the mobile web simulator the problem does not occure.

    I tried to simplify the problem by removing other pages and page-content that is obviously not involved to this problem.

    I found, that the fewer content comprised by the app, the more times the page is displayed correctly. Having only the startup screen and the info-page with almost no content, the proplem disappeared.

    If you need more information please let me know.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: phoneui.gotoPage does not work

You must be logged in to post in the forum log in