emy backButton

33 views
Skip to first unread message

Rune Back

unread,
Jun 5, 2014, 1:55:29 AM6/5/14
to iphone...@googlegroups.com
Hi

I've got all pages in one <section></section>. When changing to another page I change the content of this <section></section> This raises the need of changing the backButton so that it instead of doing something like window.history.back() it might call myFunction(myVar) where I can update the content of the <section></section>.

How do I do that?

Thank you for any help

Rune



Remi Grumeau

unread,
Jun 5, 2014, 7:02:53 AM6/5/14
to iphone...@googlegroups.com
eh eh :)
If you don't play the rules, be ready to face those kind of problems ;)

Emy deals with going from screen A to screen B by itself. If you want no transitions between screens, just set emy.transitionMode to "none"

Then going back and forward with browser prev/next buttons is supported.

Only way to do it by yourself would be to totally recreate 70% of the library, aka dealing with hash & hashChange events.
And i'm pretty sure you don't want to do that :)


Or, even worse, you can hide the backButton, and create your own backButton (just call it something else than "backButton") with the onClick you want on it.
That wouldn't support the device physical back button by the way…


Remi

--
You received this message because you are subscribed to the Google Groups "iPhoneWebDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iphonewebdev...@googlegroups.com.
To post to this group, send email to iphone...@googlegroups.com.
Visit this group at http://groups.google.com/group/iphonewebdev.
For more options, visit https://groups.google.com/d/optout.

Rune Back

unread,
Jun 5, 2014, 7:59:07 AM6/5/14
to iphone...@googlegroups.com
Hi Remi
 
No good Remi. 70%?!! - I was hoping for better news :((
 
So you go from screen A to B and to C. At C you update some information which means you also need to update screen A and B. So after the update you go straight to screen B and before doing so you update the screen and everything's ok. But ... when you at screen B hit the backButton the old info at screen A will appear. (If I remember correctly that is what will happen.)
 
No easy (almost) built-in solution? ~)
 
Regards
 
Rune
 

Remi Grumeau

unread,
Jun 5, 2014, 8:57:38 AM6/5/14
to iphone...@googlegroups.com
Nope, no easy build-in solution. Just like with native apps, you have to do your homework :)

By the way, you have events to help you with that.
beforetransition / aftertransition
Those events are triggered each time you slide from a panel to another.

Or you can directly use transitions attributes to trigger a JS function when sliding between panels
If you look at the Notes app demo
In the code you can see
<section id="note" data-title="Notes App" class="panel" data-onshow="notes.tlbManager()" data-onexit="notes.emptyForm()">
Those really helps to trigger a function at a particular moment on a particular screen


Again, If you don't care about device physical back button & browser's prev/next buttons, are on schedule / budget, you can just create your own backButton & hide Emy's one
<section id="screenA" data-title="Screen A" class="panel" data-hidebackbutton="true">
and put your own button in the toolbar's first div (for the left side) or second div (for the right side)
<a id="mybackbutton" class="button" onclick="myFunction(myVar)">Back</a>

Kind of like the "About" button in the toolbar of the same Notes demo app :)


Remi

Rune Back

unread,
Jun 6, 2014, 2:22:48 AM6/6/14
to iphone...@googlegroups.com
Hi Remi

There was a bug in my code. Got it working. - Sorry about that.

One more thing: emy.goBack() and window.history.back() - Can I use either one?

regards

Rune

Remi Grumeau

unread,
Jun 11, 2014, 9:53:36 AM6/11/14
to iphonewebdev
Always use emy.goBack() !!

That's VERY important

Remi
Reply all
Reply to author
Forward
0 new messages