Skip to content

Page reloads when subscription is changes #383

Description

@Ist14labs

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions