Navigating to the same state cause re-render page


#1

Hi. I use ionic to build rich app with one “master state”. The master state works as mediator, it includes many templates (nested views) that activates depending on url parameters. Application should looks like one view application, no transitions needed. Application should not reload pages between state changes, but url should change synchronous with changing state.

I think that this behaviour can be achieved with standard ui-router api. My application have one state, like this:

.sate('master', { url: '/master?search&document&...' ... }

I try to change state from ‘/master’ to ‘/master?search=something’ withoud re-rendering page. When i call $sate.go(’/master’, { search: ‘something’}, { notify: false }) all works fine, except one thing - ionic does not push previous state to history. I don`t want to record history by my self. When i call $state.go(’/master’, { search: ‘something’}) history updated correctly, but ionic re render my view.

I look to ionic sources, and it looks like there no chance to split history tracking with view rendering.

    // file navView.js:

    $scope.$on('$stateChangeSuccess', function() {
      updateView(false);
    });

    // function updateView(false)
    // register, update and transition to the new view
    navViewCtrl.register(viewLocals);

    // file navViewController.js
      self.register = function(viewLocals) {
          var leavingView = extend({}, $ionicHistory.currentView());

          // register that a view is coming in and get info on how it should transition
          var registerData = $ionicHistory.register($scope, viewLocals);

          // update which direction
          self.update(registerData);

          // begin rendering and transitioning
          var enteringView = $ionicHistory.getViewById(registerData.viewId) || {};

          var renderStart = (disableRenderStartViewId !== registerData.viewId);
          self.render(registerData, viewLocals, enteringView, leavingView, renderStart, true);
        };

I want to push state to history, but i don`t need to render views, because i already have actual view. It is possible to do?

Also i already tried:

  • reloadOnSearch = false - this does not work, because it`s also does not push states to history
  • state hierarchy - works fine when we change state from parent to child, but for siblings we have the same problems that in one master state.
  • $ionicHistory.nextViewOptions({disableAnimate: true}) - does nothing, only disables transition, but page still re render

#2

I create plunk with app example: http://plnkr.co/edit/0Y1ysr?p=info.

This is ionic app has one state called master {url: /master} (see script.js). There are two buttons on the state view. Each button shows hidden div with text.

I want to implement history tracking by this rules:

  • When user clicks on first button then url should be appended with firstOpened=true
  • When user clicks on second button then url should be appended with secondOpened=true
  • Controllers should stay the same (no re-initialization needed)
  • Back button of browser should undo last action, for example: If user opens first div then back button should close this div and restore url without page reload.
  • If history of master state is empty, then back button should restore previous state if it exsits

I don`t understand how i can do this. Can i reuse $ionicHistory in some way? Should i write my own history manager and integrate it with ionic in some way?