hyphens2
hyphens2

Reputation: 166

Why can't go back page after twice back to index?

I'm using Cordova + Framework 7

routes.js

{
    path: '/page1/',
    async: function (routeTo, routeFrom, resolve, reject) {
        axios.get('').then(response => {
            var data = response.data;
            resolve({
                componentUrl: './pages/page1.html'
            }, {
                context: {
                    data: data,
                }
            });
        })
    }
}, {
    path: '/page2/:id',
    async: function (routeTo, routeFrom, resolve, reject) {
        axios.get('' + id).then(function (response) {
            var data = response.data;
            resolve({
                componentUrl: './pages/page2.html'
            }, {
                context: {
                    data: data
                }
            });
        })

    }
}

Back button in page1, page2

<a href="#" class="back link" data-force="true">
    <img src="img/icon-back.png" alt="">
</a>

Button go to page1 in index.html

.html

<a href="#" class="button button-raised button-fill" id="go-page1">go page1</a>

.js

$$('#go-page1').on('click', function () {
    app.views.main.router.navigate('/page1/');

}

Button go to page2 in page1

{{#each data}}
<div class="col">
    <div class="card demo-card-header-pic">
        <a href="/page2/{{id}}">{{name}}</a>
    </div>
</div>
{{/each}}

Upvotes: 0

Views: 447

Answers (1)

Anees Hikmat Abu Hmiad
Anees Hikmat Abu Hmiad

Reputation: 3560

you can fix that by one from these solution:

1)

$$('#go-page1').on('click', function () {
    app.views.main.router.navigate('/page1/', {reloadCurrent: true});

}

2) or in html link

<a class="back" data-ignore-cache="true" data-force="true">back</a>

3) ignore cache/history or refresh prev page by reloadPrevious like this:

mainView.router.back({url: 'index.html', force: true, ignoreCache: true,reload: true});

Upvotes: 1

Related Questions