facebook

"Run Javascript" and "Go to Screen" in one action

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

    epet
    Participant

    I need some guidelines regarding a project.
    What is the correct way of approach, when you need to update a value stored in localStorage during a click of a list-item which action is a “Go to Screen” one? -Neither don’t want to post a form between them nor a php web-server page-

    Because of the two .mobi screens, if I use the “Go to Screen” action, I cannot update the localstorage value through a function in _custom.js.
    If I use the “Run Javascript” action, the 2nd screen is not available in the main screen, so I cannot use a phoneui.gotoScreen …

    All designing occurs in Design Center, so the only untouched file to tweak is the _custom.js one.

    Thanks for your time guys.

    PS. If this thread should be moved, please do. It’s my first post.

    #337109 Reply

    support-michael
    Keymaster

    >Because of the two .mobi screens, if I use the “Go to Screen” action, I cannot update the localstorage value through a function in _custom.js

    Sure you can use the <project>_custom.js file. There should only one _custom.js file in your project. Customize the specific stubbed function shown below with the side-effect to save/update storage as needed either before or after a screen transition.

    /**
     * Notification that the UI is about to transition to a new screen.
     * Perform custom prescreen-transition logic here.
     * @param {String} currentScreenId 
     * @param {String} targetScreenId 
     * @returns {boolean} true to continue transtion; false to halt transition
     */
    phoneui.prePageTransition = function(currentScreenId,targetScreenId) {
      // add custom pre-transition code here
      // return false to terminate transition
      return true;
    }
    
    /**
     * Notification that the UI has transitioned to a new screen.
     * 
     * @param {String} newScreenId 
     */
    phoneui.postPageTransition = function(newScreenId) {
      
    }
    #337111 Reply

    epet
    Participant

    Yes, I see. Thank you very much for your quick reply.

    And, to catch the caller object of the page transition (and its properties like name etc), I have to use something like $(event.srcElement) ?

    #337211 Reply

    Hi timiman,

    Yes, I believe that will work. Can I ask why you need to know the UI object that initiated the transition? My interest is to better understand if there may be some complexity here as some widgets such as selectLists and combos are implemented with separate UI and model components.

    #337221 Reply

    epet
    Participant

    Basically it has to do with a dynamic created rounded list, which items call the same function. Because of the same function called by a number of items, the need to distinguish which the caller is, is a must for later use.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: "Run Javascript" and "Go to Screen" in one action

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