Topic
  • 5 replies
  • Latest Post - ‏2013-02-08T00:17:29Z by SystemAdmin
enrico.visentini
enrico.visentini
5 Posts

Pinned topic multi page application transition event

‏2013-02-05T09:07:34Z |
Hi all,
I'm developing a mobile app with multi page template, using also a separated js files for each html page.
From the main page that contains the main view, by clicking a button, the context moves to a second view that is in second html page and it works fine.
My problem is that I need to call a js function when the second view is loaded, for set some date, but I can't find a way to do that.
I've read about dojo.connect, or onAfterTransitionIn but there are no examples for use these functions in WL.
Can anyone tell me how to do it, or the best practice to handle this problem?
Any help is appreciated.
Thanks

Enrico
  • Eric Durocher
    Eric Durocher
    38 Posts

    Re: multi page application transition event

    ‏2013-02-05T15:13:55Z  
    Hi Enrico,

    Right, when you use "external" or dynamic views as you do, it is not obvious to listen to transition events on the destination view since it is created on the fly.

    So I would say the easiest way is to use the global "topics" emmitted during transitions, you can find an example of this here:

    http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/mobile/tests/test_transition-pubsub.html

    Basically the idea is to listen globally to view transitions using topic.subscribe:

    http://dojotoolkit.org/reference-guide/1.8/dojo/topic.html#subscribe

    (Note the sample above uses the "old" syntax, i.e. connect.subscribe, it is better to use the new topic.subscribe syntax).

    Hope this helps.

    Eric
  • enrico.visentini
    enrico.visentini
    5 Posts

    Re: multi page application transition event

    ‏2013-02-05T16:08:26Z  
    Hi Enrico,

    Right, when you use "external" or dynamic views as you do, it is not obvious to listen to transition events on the destination view since it is created on the fly.

    So I would say the easiest way is to use the global "topics" emmitted during transitions, you can find an example of this here:

    http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/mobile/tests/test_transition-pubsub.html

    Basically the idea is to listen globally to view transitions using topic.subscribe:

    http://dojotoolkit.org/reference-guide/1.8/dojo/topic.html#subscribe

    (Note the sample above uses the "old" syntax, i.e. connect.subscribe, it is better to use the new topic.subscribe syntax).

    Hope this helps.

    Eric
    Thanks Eric,
    but I can't understand where to use it into WL application. The first link uses views that are in the same HTML page, but in my case view2 is in another HTML file and until the view2 is not called, the object doesn't exists.
    Can you suggest an example for how to use topic.subscribe()?

    Thank!

    P.S. I solved my problem by inserting in view2 the following code, but I think is not a good practice for handle this kind of events:



    .....

  • enrico.visentini
    enrico.visentini
    5 Posts

    Re: multi page application transition event

    ‏2013-02-05T16:12:36Z  
    Thanks Eric,
    but I can't understand where to use it into WL application. The first link uses views that are in the same HTML page, but in my case view2 is in another HTML file and until the view2 is not called, the object doesn't exists.
    Can you suggest an example for how to use topic.subscribe()?

    Thank!

    P.S. I solved my problem by inserting in view2 the following code, but I think is not a good practice for handle this kind of events:



    .....

    Sorry, the code is:

    div data-dojo-type="dojox.mobile.ScrollableView" id="orderSearchView"
    data-dojo-props="selected:false,scrollDir:'v'" onAfterTransitionIn="setCurrent();">

    .....

    /div>
  • Eric Durocher
    Eric Durocher
    38 Posts

    Re: multi page application transition event

    ‏2013-02-05T16:25:37Z  
    Sorry, the code is:

    div data-dojo-type="dojox.mobile.ScrollableView" id="orderSearchView"
    data-dojo-props="selected:false,scrollDir:'v'" onAfterTransitionIn="setCurrent();">

    .....

    /div>
    OK, I thought you wanted to set the handler from the first view... Well if that solution works for you I don't really see anything wrong with it, you should just include the onAfterTransitionIn setter inside data-dojo-props for HTML5 compliance.

    Regards,

    Eric
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: multi page application transition event

    ‏2013-02-08T00:17:29Z  
    Sorry, the code is:

    div data-dojo-type="dojox.mobile.ScrollableView" id="orderSearchView"
    data-dojo-props="selected:false,scrollDir:'v'" onAfterTransitionIn="setCurrent();">

    .....

    /div>
    Note: IBM forums are in the process of migrating to a new format. During migration the forums will be frozen and in read-only mode. If you wish to continue this thread discussion please post it on stackoverflow, where the Worklight team and others can respond.

    See the Forum Migration announce post for more details. Thank you.

    Barbara Hampson, Manager, IBM Worklight