Hybrid View

  1. #1
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    San Diego, CA
    Posts
    158
    Vote Rating
    0
    locutusUT is on a distinguished road

      0  

    Default A better way to implement Back Button in Sencha Touch’s NavigationView

    A better way to implement Back Button in Sencha Touch’s NavigationView


    Check out my blog on how to implement a simple device/browser back button solution here. I've tested it successfully on several different phones including Android and iOS.

  2. #2
    Sencha User
    Join Date
    Feb 2011
    Location
    Düsseldorf, Germany
    Posts
    579
    Vote Rating
    32
    Kurt001 has a spectacular aura about Kurt001 has a spectacular aura about

      0  

    Default Very cool

    Very cool


    I like that.
    So far I was writing my own history controller to make sure I get the history I want, wiht the option to jump back to certain places.
    But never used the history states.
    Man - this really rocks and is so simple.

    Porbalbly an override would do for the launch method.

    About Android. Usually I add a event listener to Ext.Viewport.down('button[ui=back]') and do: setHidden(true).

    As Android usually should be only used with the hardware back-button.

    My way to do this is to listen to the hashchange event and pop the active item from the sencha history. At the same time I keep the sencha history to a minimum, so that sencha does not get confused, with what to do. So basically I keep it like a hashmap.

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Location
    Düsseldorf, Germany
    Posts
    579
    Vote Rating
    32
    Kurt001 has a spectacular aura about Kurt001 has a spectacular aura about

      0  

    Default


    Why do you not use replaceState() ?
    You are not working with routes at all?

  4. #4
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    San Diego, CA
    Posts
    158
    Vote Rating
    0
    locutusUT is on a distinguished road

      0  

    Default


    Thanks Kurt for the comments...

    Why pollute your application with a bunch of routing logic if it's not needed? This is the most elegant solution I've found and it works beautifully across many devices.

    Also, my blot post talks about using with NavigationView...I wouldn't want to do this at the Viewport level because I want back button to be different depending the NV tab I'm on. Does that make sense?

  5. #5
    Sencha User
    Join Date
    Feb 2011
    Location
    Düsseldorf, Germany
    Posts
    579
    Vote Rating
    32
    Kurt001 has a spectacular aura about Kurt001 has a spectacular aura about

      0  

    Default



  6. #6
    Sencha User armode's Avatar
    Join Date
    Nov 2011
    Location
    Germany / Darmstadt
    Posts
    64
    Vote Rating
    4
    armode is on a distinguished road

      0  

    Default


    Thanks for sharing, this is an awesome and elegant idea!

    I'm working on a ST app, that exists since ST1 and isn't still 100% MVC; that's why I had my own simple history for my back button. It's just an array of view IDs. But I never thougt about this history solution. It was really easy to implement on top of my back button logic and brings a big improvement for my Android customers.

    Thanks again