Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page reloads when subscription is changes #383

Open
Ist14labs opened this issue Jan 23, 2017 · 0 comments
Open

Page reloads when subscription is changes #383

Ist14labs opened this issue Jan 23, 2017 · 0 comments

Comments

@Ist14labs
Copy link

I want to implement infinite scroll pagination by Iron.Router state variables.

That is my subscription code:

Router.route('/categories/', {
    loadingTemplate: 'loading',
    waitOn: function () {
        var limit=parseInt(this.state.get('limit'))||10;
        return Meteor.subscribe('categories', {}, {limit:limit});
    },
    action: function () {
        if(!this.state.get('limit')){
            this.state.set('limit',10);
        }
        this.render('categories', {
            data: {
               categories:Categories.find()
            }
        });
    }
});

My publication code:

Meteor.publish('categories', function (query, params) {
    return Categories.find(query, params)
});

And my template:

<template name="categories">
    {{#contentFor "headerTitle"}}
        <h1 class="title">Sections</h1>
    {{/contentFor}}
    {{#ionView}}
        {{#ionContent}}
            {{#ionList class="my-class"}}
                {{#each categories}}
                    {{#ionItem href=getHref avatar=true}}
                        <img src="{{image}}">
                        <h2>{{title}}</h2>
                    {{/ionItem}}
                {{/each}}
            {{/ionList}}
        {{/ionContent}}
    {{/ionView}}
</template>

So, when I'm call Router.state.set('limit', 20) I expect that items just be added at the end of list, but I get full page reload, including animation of page and reset of scroll position. Is there a way to turn off that behavior when changing router state?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant